fw-file
Introduction
fw-file
is a Python package that provides a unified interface for working with various file formats commonly used in neuroimaging and medical research. It simplifies file parsing, metadata extraction, and format conversion, making it easier to work with complex file types in Flywheel and other applications.
Key Features
- Unified Interface: Consistent API for working with different file formats
- Metadata Extraction: Extract metadata from various file types
- Format Conversion: Convert between different file formats
- Validation: Validate file integrity and format compliance
- Extension System: Extensible architecture for adding support for new file types
Supported File Types
fw-file
supports a wide range of file formats, including:
Medical Imaging
- DICOM
- NIfTI1 and NIfTI2 (.nii.gz)
- Bruker ParaVision (subject/acqp/method)
- GE MR RAW / PFile (P_NNNNN_.7)
- Philips MR PAR/REC header (.par)
- Philips MR PAR/REC zipfile (.parrec.zip) (read-only)
- Siemens MR RAW (.dat)
- Siemens MR Spectroscopy (.rda)
- Siemens PET RAW (.ptd)
- PNG (.png)
- JPEG/JPG (.jpeg/.jpg)
- BrainVision EEG (.vhdr/.vmrk/.eeg)
- EEGLAB EEG (.set/.fdt)
- European Data Format EEG (.edf)
- BioSemi Data Format EEG (.bdf)
- JSON
Installation
Usage Examples
Opening
Fields
Attribute access on DICOMs works similarly to that in pydicom
:
Key access also returns values instead of pydicom.DataElement
:
Private tags can be accessed as keys when including the creator:
Assignment and deletion works with attributes and keys alike:
Metadata
Flywheel metadata can be extracted using the get_meta()
method:
Saving
Collections and series
Handling multiple DICOM files together is a common use case, where the tags of more than one file need to be inspected in tandem for QA/validation or even modified for de-identification. DICOMCollection
facilitates that and exposes convenience methods to be loaded from a list of files, a directory or a zip archive.
To interact with the underlying DICOMs:
Finally, a DICOMCollection
can be saved in place, exported to a directory or packed as a zip archive:
Resources
Related Packages
- fw-gear: Package for developing Flywheel gears
- fw-classification: Package for classifying medical imaging data