Package: radifox
RADIFOX is an organization and management system for medical images.
There are multiple components under the RADIFOX umbrella:A detailed, type-based naming system for medical images (including a Python API)An organizational system flexible enough for a multitude of study designsA conversion system to convert from DICOM to NIfTI using DCM2NIIXA auto-provenance system to track the provenance of processing resultsA web-based quality assurance systemRADIFOX is designed to be flexible and extensible.Table of ContentsOverviewInstallationBasic UsageCLI Scriptsradifox-convertradifox-updateradifox-qaPython APIImageFileImageFilterProcessingModuleRADIFOX ComponentsFile OrganizationNamingConversionLook-up TablesManual NamingJSON Sidecar FilesProvenanceQuality AssuranceAdditional InformationAdvanced CLI Usageradifox-convertradifox-updateradifox-qaJSON Sidecar FormatContainer CreationOverviewThe core of the RADIFOX system is the naming and organization system.
This system is designed to be flexible, but also can be opinionated.
The directory organization can be simplified to:<output-root>/<project-id>/<subject-id>/<session-id>/...The naming system is a detailed, type-based naming system optimized for medical images.
It can be simplified to:<subject-id>_<session-id>_<image-id>_<image-type>.extThe image type can be futher broken down into a number of components:<bodypart>-<modality>-<technique>-<acqdim>-<orientation>-<excontrast>[-<extras>]This organzation allows for the implementation of features such as auto-provenance.InstallationRADIFOX is available on PyPI and can be installed with pip:pipinstallradifoxThis base install will cover the core functionality of RADIFOX.
However, to run conversions, you will need thedcm2niixtool installed on your system (and included in your PATH).To include the dependencies for the web-based quality assurance system, install with theqaextra:pipinstallradifox[qa]Basic UsageCLI ScriptsTheradifoxpackage includes a number of CLI scripts to access various components of RADIFOX.
These scripts are installed to your PATH when you install theradifoxpackage.
For a full listing of command line options, seeAdvanced CLI Usage.radifox-convertTheradifox-convertscript is used to convert DICOM files to NIfTI files using thedcm2niixtool.
It is a wrapper arounddcm2niixthat uses the RADIFOX naming system to organize the output files.Example Usage:radifox-convert\--output-root/path/to/output\--project-idstudy\--subject-id123456\--session-id1\/path/to/dicom_filesThis will copy the files in the direction/path/to/dicom_filesto the output directory/path/to/output/study/123456/STUDY-1/dcm, organize them and convert them to NIfTI.
The NIfTI files (and their JSON sidecar files) will be placed in/path/to/output/study/STUDY-123456/1/nii.radifox-updateTheradifox-updatescript is used to update naming for a directory of images.
This is commonly done after an update to RADIFOX to ensure that all images are named according to the latest version of the naming system.
It also could be done to incorporate a new look-up table or manual naming entries after QA.Example Usage:radifox-update--directory/path/to/output/study/STUDY-123456/1This will update the naming for all images in the existing RADIFOX session directory/path/to/output/study/STUDY-123456/1.
If the RADIFOX version, look-up table, or manual naming entries have changed, the images will be renamed to reflect the new information.
If none of these have changed, the update will be skipped.radifox-qaTheradifox-qascript is used to run the web-based quality assurance system.Example Usage:radifox-qa--port8888--root-directory/path/to/outputThis will launch the QA webapp on port 8888, pointing to/path/to/output.
The QA webapp will be accessible athttp://localhost:8888and will show projects in/path/to/output.
Be sure to note the secret key printed to the terminal when the app starts.
You will need this to log into the webapp.
The secret key changes each time the app is launched.You can specify your own secret key using the--secret-keyoption.radifox-qa--port8888--root-directory/path/to/output--secret-keymy-secret-key'radifox-stage'"Staging" is the process of filtering images for processing.radifox-stageis a processing module that is uses ImageFilters to accomplish this.radifox-stagelooks over an entire subject and filters images based on provided--image-types.
By default, all images matching the filter will be staged for processing.
To keep only the best resolution images for each filter, use the--keep-best-resoption.
Additionally, it can generate registration targets based on provided--reg-filters.
Plugins derived from theStagingPluginabstract class can be used to add additional functionality toradifox-stage.
Two default pluginsMEMPRAGEPluginandMP2RAGEPluginare included with RADIFOX.
These can be skipped by providing the--skip-default-pluginsoption.
Staged results have the sform and qform matrices set to be equal by default.
To skip this, use the--skip-set-sformoption.A good default call ofradifox-stagemight be:radifox-stage\--keep-best-res\--subject-dir/path/to/output/study/STUDY-123456\--image-types\'bodypart=BRAIN;modality=T1;excontrast=PRE'\'bodypart=BRAIN;modality=T1;excontrast=POST'\'bodypart=BRAIN;modality=T2'\'bodypart=BRAIN;modality=PD'\'bodypart=BRAIN;modality=FLAIR'\--reg-filters\'bodypart=BRAIN;modality=T1;acqdim=3D;excontrast=PRE'\'bodypart=BRAIN;modality=T1;acqdim=3D;excontrast=POST'\'bodypart=BRAIN;acqdim=3D'\'bodypart=BRAIN;acqdim=2D'Python APITheradifoxpackage also includes a Python API for accessing additional components.ImageFileTheImageFileclass is used to represent a single image file, including its name and metadata.
It is a wrapper around a lot ofpathlib.Pathfunctions, so it can be used in place of aPathobject in many cases.
It additionally defines a number of properties to access naming breakdowns and metadata.Example Usage:fromradifox.namingimportImageFileimg=ImageFile('/path/to/output/study/STUDY-123456/1/nii/STUDY-123456_01-03_BRAIN-T1-IRFSPGR-3D-SAGITTAL-PRE.nii.gz')print(img.body_part)# prints 'BRAIN'print(img.modality)# prints 'T1'print(img.parent)# prints Path object for '/path/to/output/study/STUDY-123456/1/nii'print(img.name)# prints 'STUDY-123456_01-03_BRAIN-T1-IRFSPGR-3D-SAGITTAL-PRE.nii.gz'print(img.info.series_description)# prints 'IRFSPGR 3D SAGITTAL PRE'Multiplepathlib.Pathfunctions are available directly (likePath.name) and others are available through thepathproperty (likePath.iterdir).
These functions will returnPathobjects, notImageFileobjects.print(img.path)# prints Path object for '/path/to/output/study/STUDY-123456/1/nii/STUDY-123456_01-03_BRAIN-T1-IRFSPGR-3D-SAGITTAL-PRE.nii.gz'ImageFilterTheImageFilterclass is used to represent a filter for images based on naming.
It is a wrapper around adictthat defines a set of key-value pairs that must be present in the image name.
It can be defined as keyword arguments in the class constructer or by passing a formatted string toImageFile.from_string.Example Usage:fromradifox.namingimportImageFilterimgs=[ImageFile('/path/to/output/study/STUDY-123456/1/nii/STUDY-123456_01-03_BRAIN-T1-IRFSPGR-3D-SAGITTAL-PRE.nii.gz'),ImageFile('/path/to/output/study/STUDY-123456/1/nii/STUDY-123456_01-04_BRAIN-T2-FSE-2D-AXIAL-POST.nii.gz'),]filt=ImageFilter(body_part='BRAIN',modality='T1')print(filt)# prints "body_part=BRAIN,modality=T1"print(filt.filter(imgs))# prints ['/path/to/output/study/STUDY-123456/1/nii/STUDY-123456_01-03_BRAIN-T1-IRFSPGR-3D-SAGITTAL-PRE.nii.gz']filt=ImageFilter.from_string('body_part=BRAIN,modality=T2')print(filt)# prints "body_part=BRAIN,modality=T2"print(filt.filter(imgs))# prints ['/path/to/output/study/STUDY-123456/1/nii/STUDY-123456_01-04_BRAIN-T2-FSE-2D-AXIAL-POST.nii.gz']ProcessingModuleTheProcessingModuleclass is used to represent a processing module for use in the auto-provenance system.
Module code should inherit from this class and implement thecliandrunmethods, as well as define thenameandversionclass attributes.
Theclimethod should take either a list of options/arguments or None to pull fromsys.argv.
It should return adictof keywards and arguments to pass directly to therunmethod.
Therunmethod should take adictof keywords and arguments and return adictof results.Example Usage:importargparseimportloggingfrompathlibimportPathimportnibabelasnibfromradifox.recordsimportProcessingModuleclassMyModule(ProcessingModule):name="my-module"version="1.0.0"@staticmethoddefcli(args=None):parser=argparse.ArgumentParser()parser.add_argument("--input",type=Path,required=True)parser.add_argument("--mult-factor",type=float,required=True)parsed=parser.parse_args(args)return{"input":parsed.input,"mult_factor":parsed.mult_factor,}@staticmethoddefrun(in_file:Path,mult_factor:float):out_stem=in_file.name.split(".")[0]out_dir=in_file.parent.parent/"proc"out_dir.mkdir(exist_ok=True,parents=True)logging.info(f"Multiplying{in_file}by{mult_factor}.")obj=nib.Nifti1Image.load(in_file)data=obj.get_fdata()new_obj=nib.Nifti1Image(data*mult_factor,obj.affine,obj.header)new_obj.to_filename(out_dir/f"{out_stem}_mult-{mult_factor}.nii.gz")return{'output':out_dir/f"{out_stem}_mult-{mult_factor}.nii.gz"}AProcessingModulesubclass can then be run asMyModule()orMyModule(args)(where args is as list of strings forargparseto parse).
This can be used to make a processing script by adding:if__name__=="__main__":MyModule()to the end of the file.StagingPluginTheStagingPluginclass is used to represent a plugin for use in theradifox-stagemodule.
Plugins should inherit from this class and implement thefilterandrunmethods.
Thefiltermethod should take a list ofImageFileobjects and return a list ofImageFileobjects.
The most common way to achieve this would be to define anImageFilterand use thefiltermethod of that class.
Therunmethod should take a list ofImageFileobjects and return a list ofImageFileobjects.
This method should perform the actual processing of the images.Below is an example that calculates the sum of a list of multi-echo images of an MEMPRAGE acquisition.importnibabelasnibimportnumpyasnpfromradifox.namingimportImageFile,ImageFilterfromradifox.modulesimportStagingPluginclassMEMPRAGEPlugin(StagingPlugin):@staticmethoddeffilter(images:list[ImageFile])->list[ImageFile]:returnImageFilter(modality="T1",technique="IRFSPGR",extras=lambdax:any("ECHO"insors=="SUM"forsinx),).filter(images)@staticmethoddefrun(images:list[ImageFile])->list[ImageFile]:out_imgs=[]forimg_setinMEMPRAGEPlugin.sort_by_series(images):# Choose a SUM image if both echoes and SUM are availablesum_imgs=[imgforimginimg_setif"SUM"inimg.extras]ifsum_imgs:out_imgs.append(sum_imgs[0])else:out_imgs.append(MEMPRAGEPlugin.sum_memprage(img_set))returnout_imgs@staticmethoddefsum_memprage(imgs:list[ImageFile])->ImageFile:"""Create a sum image from a list of MEMPRAGE echo images."""temp_img=sorted(imgs,key=lambdax:x.name)[0]out_fpath=temp_img.path.parent.parent/"stage"/f"{temp_img.stem}_sum.nii.gz"obj=nib.load(temp_img.path)sum_data=np.sum([nib.Nifti1Image.load(img.path).get_fdata(dtype=np.float32)forimginimgs],axis=0)nib.Nifti1Image(sum_data,None,obj.header).to_filename(out_fpath)returnImageFile(out_fpath)RADIFOX ComponentsRADIFOX is a collection of components that work together to provide a comprehensive system for managing medical images.File OrganizationThe file organization structure is multi-level allowing for multiple projects to be stored together while being easily separated.
The directory structure is as follows:<root-directory>
└── <project-id>
    └── <subject-id>
        └── <session-id>This is easily extensible to include multiple sessions per subject, multiple subjects per project, and multiple projects per root directory.
Theproject-id,subject-id, andsession-idare all user-defined and can be any string.For example:/path/to/output
└── study
    └── STUDY-123456
        └── 1
        └── 2
    └── STUDY-789012
        └── 1
        └── 2Note: Thesubject-idis prefixed with theproject-idto ensure that thesubject-idis unique across projects.Within each session directory, there are a number of subdirectories that are the same for every session:...
└── <session-id>
    └── dcm
    └── nii
    └── logs
    └── qaThedcmdirectory is where the original DICOM files are stored.
Theniidirectory is where the converted NIfTI files (and JSON sidecars) are stored.
Thelogsdirectory is where the logs from processing are stored.
Theqadirectory is where the images for QA are stored.In addition to these directories, there are a few files that stored in the session directory.
The<subject-id>_<session-id>_UnconvertedInfo.jsonfile is a JSON file that contains information from DICOM files that were skipped during conversion.
The<subject-id>_<session-id>_ManualNaming.jsonfile is a JSON file that contains manual naming entries for images in the session.
The<subject-id>_<session-id>_Provenance.txtfile is a text file that contains the provenance of the processing steps for the session.After processing starts, a few other directories will be added to the session directory:...
└── <session-id>
    └── proc
    └── stage
    └── tmpTheprocdirectory is where the processed images and fiels are stored.
Thestagedirectory is where the filtered images are placed prior to processing.
Thetmpdirectory is where intermediate files are stored during processing.NamingThe RADIFOX naming system is a detailed, type-based naming system for medical images.
It is currently focused on MRI images, but it is expected to extend to other modalities.
There are six main components to the naming system:bodypart: The body part being imaged (e.g. BRAIN, CSPINE, etc.)modality: The imaging modality (e.g. T1, T2, etc.)technique: The imaging technique (e.g. IRFSPGR, FSE, etc.)acqdim: The acquisition dimension (2D or 3D)orientation: The imaging plane (AXIAL, SAGITTAL, CORONAL)excontrast: The exogenous contrast (PRE, POST, etc.)An image filename is then constructed by combining these components with hyphens.<subject-id>_<session-id>_<image-id>_<bodypart>-<modality>-<technique>-<acqdim>-<orientation>-<excontrast>.nii.gzTheimage-idis a unique identifier for the image within the session, it is created from a study number (in case multiple imaging studies are in the same session) and an image number (in each study).Additionally, image names can haveextrasappended to the end of the core name.
These are additional descriptors that are not part of the core naming system, but are useful for identifying images.extrasare connected to the main name with a hyphen (and multiple extras are separated by hyphens).
Common uses forextrasare echo numbers (e.g. ECHO1, ECHO2, etc.) in multi-echo sequences and complex image components (like MAG and PHA) in complex images.
However, this can be used for any additional descriptor of the acquired image that may help route it through processing.For example:STUDY-123456_01-03_BRAIN-T2-FSE-2D-AXIAL-PRE-ECHO1.nii.gz
STUDY-123456_01-03_BRAIN-T2-FSE-2D-AXIAL-PRE-ECHO2.nii.gzProcessed images also have tags appended to the end of the name.
This is to indicate the processing steps that were applied to the image.
These tags are separated from the main name with an underscore (and multiple tags are separated by underscores).
In general, new tags are appended to existing tags (so the order of tags is important).
This is to ensure that the processing history of the image is preserved in the filename.For example:STUDY-123456_01-03_BRAIN-T2-FSE-2D-AXIAL-PRE-ECHO1_n4.nii.gzConversionThe conversion system is a wrapper around thedcm2niixtool.
It uses the RADIFOX naming system to organize the output files.radifox-convertis the core command for this function.The conversion process is as follows:Copy the DICOM files to thedcmdirectory in the session directory.Sort the DICOM files into series directories in thedcmdirectory and remove any duplicates.Check for series that should be skipped (scouts, localizers, derived images, etc.).Generate image names automatically from the DICOM metadata, look-up tables, and manual naming entries.Convert the DICOM files to NIfTI usingdcm2niixand rename to RADIFOX naming.Create the JSON sidecar files for the NIfTI files (contains some DICOM metadata).Create QA images for the converted NIfTI files.Look-up TablesThe look-up tables are a set of rules for automatically naming images based on the DICOMSeriesDescriptiontag.
They are stored in a comma-separated values (CSV) file in each project folder.
They have a specific name format:<project-id>_lut.csv.
If no look-up table is found for a project, a blank look-up table is written.
Look-up table values take precidence over automatic naming, but are overwritten by manual names.The look-up table file has five total columns:Project,Site,InstitutionName,SeriesDescription, andOutputFilename.The first three columns (Project,Site, andInstitutionName) narrow down which images are affected.
These columns match the project and site IDs and the DICOMInstitutionNametag.
This means that if a particular site or even scanning center uses a specificSeriesDescription, it can be handled differently than others.
TheSiteandInstitutionNamecolumns are optional and can beNone.TheSeriesDescriptioncolumn is a string and mustexactlymatch the DICOMSeriesDescriptiontag.
This may mean that multiple rows are needed to cover all possible values of theSeriesDescriptiontag for a particular name.TheOutputFilenamecolumn is where the RADIFOX naming is specified.
You do not have to specify all components of the name, only the ones that need to be changed.
For example, if you only want to change thebodyparttoBRAINfor a specificSeriesDescription, you can specifyBRAINin theOutputFilenamecolumn.
However, you must specify all components that come prior to the one you want to change asNone.
For example, to change themodalitytoT1for a specificSeriesDescription, you must specifyNone-T1in theOutputFilenamecolumn.
This can also be used to change theextras, by specifying them at the end of theOutputFilenamecolumn.
For example, to addECHO1to the end of the name for a specificSeriesDescription, but change nothing else, you must specifyNone-None-None-None-None-None-ECHO1in theOutputFilenamecolumn.Manual NamingManual naming entries are the most specific way to name images.
They are stored as a JSON file in each session directory (<subject-id>_<session-id>_ManualNaming.json).
This JSON file is a dictionary with the DICOM series directory path (dcm/...) as the key and the new name as the value.
This series path can be found as theSourcePathin the sidecar JSON file for the image.
Manual naming entries take precidence over look-up tables and automatic naming.
The naming convention for manual naming entries is the same as for look-up tables.The simplest way to create manual naming entries is to use theradifox-qawebapp.JSON Sidecar FilesJSON sidecar files are created for each NIfTI file during conversion.
They contain information about the conversion process (versions, look-up table values, manual naming, etc.) as well as critical DICOM metadata.
The JSON sidecar files are stored in theniidirectory in eact session directory next to their corresponding NIfTI file.Sidecar files are human-readable, but can also be accessed in Python using thejsonstandard package.
Most of the crutial information will be in theSeriesInfokey of the sidecar file.importjsonobj=json.load(open('/path/to/output/study/STUDY-123456/1/nii/STUDY-123456_01-03_BRAIN-T1-IRFSPGR-3D-SAGITTAL-PRE.json'))print(obj['SeriesInfo']['SeriesDescription'])# prints 'IRFSPGR 3D SAGITTAL PRE'print(obj('SeriesInfo')['SliceThickness'])# prints 1.0A complete record of the sidecar JSON format is belowJSON Sidecar Format.ProvenanceThe auto-provenance system is a system for tracking the provenance of processing results.
It allows developers to easily include RADIFOX management features into their processing scripts in a consistent way.
This includes automatic generation of provenance records, automatic logging during execution and automatic generation of QA images from outputs.The auto-provenance system is based on theProcessingModuleclass.
This is an abstract class that defines the basic structure of a processing module.
Developers should inherit from this class and implement thecliandrunmethods, as well as define thenameandversionclass attributes.
SeeProcessingModulefor more details.Provenance RecordsProvenance from this system is stored in two different ways.
The first is at the session level in the<subject-id>_<session-id>_Provenance.ymlfile.
This is an append-only text file that contains the provenance records of all processing steps for the session.
The second is a provenance text file (.prov) that is stored with each processed file.
This contains the provenance record for the process that created the processed file only.Provenance records are stored in the YAML format that is human-readable, but also easily parsed by Python.
The format is as follows:---Id:<record-id>Module:<module-name>:<module-version>Container:url:<container-url>:<container-tag>@<container-commit>hash:<container-hash>builder:<container-builder>timestamp:<container-timestamp>User:<user-name>@<hostname>StartTime:<start-timestamp>Duration:<duration-days-hours-minutes-seconds>Inputs:<input-key-1>:<input-filename-1>:<input-hash-1><input-key-2>:-<input-filename-2>:<input-hash-2>-<input-filename-3>:<input-hash-3>Outputs:<output-key-1>:<output-filename-1>:<output-hash-1><output-key-2>:-<output-filename-2>:<output-hash-2>-<output-filename-3>:<output-hash-3>Parameters:<parameter-key-1>:<parameter-value-1><parameter-key-2>:<parameter-value-2>Command:<command-string>...The<record-id>is a unique identifier for the record created from a hash of the rest of record.
The<module-name>and<module-version>are the name and version of the processing module that created the record (defined inProcessingModulesubclass).
The<container-url>,<container-tag>,<container-commit>and<container-hash>values are the URL, tag, commit, and hash of the container used to run the processing module.
The<container-timestamp>,<container-builder>values are the timestamp and builder identity of the container used to run the processing module.
These are derived from specific labels set during container creation.
For more information on how compatible containers are created, seeContainer Creation.
The<user-name>and<timestamp>are the user name of the user that ran the processing module and the timestamp of the processing module run completion.
The<input-key>s,<input-filename>s, and<input-hash>s are the input names, filenames, and hashes of the input files to the processing module.
Outputs are structured the same way.
The<parameter-key>s and<parameter-value>s are the key-value pairs of the parameters passed to the processing module (that are not files).
The<command-string>is the exact command string that was used to run the processing module.Automatic LoggingThe auto-provenance system also includes automatic logging during execution.
This is done by setting up alogginghandler that writes to thelogsdirectory in the session directory.
This handler is set up by default to log all messages to thelogs/<module-name>/<first-input-filename>-<timestamp>-info.logfile.
This can be adjusted tologs/<module-name>-<timestamp>-info.logby settinglog_uses_filenametoFalsein theProcessingModulesubclass.
Currently, there is support forINFO,WARNINGandERRORlevel messages.
They can be accessed at any point in therunmethod by callinglogging.info(message)(orwarningorerror).
You must importloggingat the top of the file to use this feature.
If there are warnings or errors produced during execution, they will be written to additional log files (-warning.logand-error.log) for easy viewing.
There is currently no support forDEBUGlevel messages, but that is planned for the future.Automatic QA ImagesThe auto-provenance system also includes automatic generation of QA images from outputs.
Any output that is returned from therunmethod will have a QA image generated automatically, if it is a NIfTI file (ends in.nii.gz).Quality AssuranceThe web-based quality assurance system is a system for viewing images and recording QA results.
It is a Flask-based webapp that can be run locally.
There are two modes:conversionandprocessingthat can be switched between using the links in the top navigation bar.Theconversionmode is used to view and make corrections to the naming of images after conversion.
There are three types of actions that can be taken inconversionmode.Ignore Button: This will mark the image to be skipped by the conversion process on update.Body Type Buttons: This will change thebodypartof the image to the selected value. It is currently available forBRAIN,CSPINE,TSPINE,LSPINE, andORBITS.Correct Name Button: This will open a form to correct any of thecoreaspects of the RADIFOX naming convention.extrasare not yet supported.Theprocessingmode is used to view outputs of various processing steps.
For each processing step, images of the outputs are shown with the provenance record for that step.
No actions are currently availabe inprocessingmode, but we hope to record QA results directly from the app.The QA webapp is launched with theradifox-qacommand.
It is a webapp that runs locally on port 5000 by default.
Be sure to copy down the Secret Key that is printed to the console when the webapp is launched.
This will be required to log into the webapp and changes each time the app is launched.
It can also be specified using the--secret-keyoption.
For convenience, you can log into the app usinghttp://{HOST}:{PORT}/login?key={SECRET_KEY}, which is printed when the app is launched.
It can also be accessed athttp://{HOST}:{PORT}(http://localhost:5000by default) and the key can be entered there.
Seeradifox-qaabove for more details.Additional InformationAdvanced CLI Usageradifox-convertOptionDescriptionDefaultsourceThe source directory (or zip file) containing the DICOM files.required-o,--output-rootThe root directory for the output files (contains project directories).required-p,--project-idThe project ID for the converted session.required-s,--subject-idThe subject ID for the converted session.required-e,--session-idThe session ID for the converted session.required-l,--lut-fileThe look-up table file to use for naming.<output-root>/<project-id>/<project-id>_lut.csv--site-idThe site ID for the converted session.None--forceForce conversion even if session directory already exists.False--recklessSkip consistency checks when forcing run (will overwrite files!)False--safeIf the session directory already exists, use a new directory with-#appended (does not change session ID or filenames)False--no-project-subdirDo not create a project subdirectory in the output root directory. Subjects will be placed directly into the--output-rootdirectoryFalse--symlinkCreate symlinks to the original DICOM files instead of copying them.False--hardlinkCreate hardlinks to the original DICOM files instead of copying them.False--verboseLog debug output.False--versionOutput RADIFOX version and exit.False--helpShow help message and exit.False--parrecConvert PAR/REC files instead of DICOM files.False--institution-nameThe institution name to use for the session (required for PAR/REC conversion).None--magnetic-field-strengthThe magnetic field strength to use for the session (required for PAR/REC conversion).None--anonymizeExperimental anonymization support (will remove copied DICOM files).False--date-shift-daysThe number of days to shift the date by during anonymization.None--tms-metafileThe TMS metafile to use for subject, site and session ID.Noneradifox-updateOptionDescriptionDefaultdirectoryThe converted RADIFOX directory to update.required-l,--lut-fileThe look-up table file to use for naming.<directory>/../<project-id>_lut.csv--forceForce conversion even if session directory already exists.False--verboseLog debug output.False--versionOutput RADIFOX version and exit.False--helpShow help message and exit.Falseradifox-qaOptionDescriptionDefault--portThe port to run the QA webapp on.5000--hostThe host bind address for the QA webapp.localhost--root-directoryThe output root to read projects from (contains project directories)/data--secret-keyThe secret key to use for the QA webapp.None--workersNumber of workers to use for web server.1radifox-stageOptionDescriptionDefault--subject-dirThe path to the subject directory to stage.required--image-typesA set ofImageFilterstrings used to filter the images for stagingrequired--reg-filtersA set ofImageFilterstrings used for determining registration targets.None--keep-best-resOnly keep the highest resolution image for each filter.False--plugin-pathsA list of additional plugin paths to add.None--skip-default-pluginsSkip the default plugins included with staging.False--skip-set-sformSkip setting the sform matrix for staged images.FalseJSON Sidecar FormatThe JSON sidecar format is a dictionary with 8 top-level keys:__version__: A dictionary of software versions used in conversion (radifoxanddcm2niix)InputHash: A hash of the input directory or archive file used in conversionLookupTable: A dictionary of look-up table values used in conversion (limited by project/site ID/institution, if applicable)ManualNames: A dictionary of manual name entries used in conversionMetadata: A dictionary of session level metadata items (Project ID, Subject ID, Session ID, etc.)RemoveIdentifiers: A boolean indicating if identifiers were removed from the converted filesSeriesInfo: A dictionary of DICOM metadata and conversion information for each converted imageTheSeriesInfovalue has most of the information about the converted image, including converted DICOM tags.AcqDateTime: The acquisition date and time of the imageAcquiredResolution: The acquired, in-plane resolution of the image (list of 2 floats)AcquisitionDimension: The number of acquisition dimensions (2D or 3D)AcquisitionMatrix: The acquired in-plane matrix size of the image (list of 2 ints)BodyPartExamined: The body part examined in the imageComplexImageComponent: The complex number component represented in the image (MAGNITUDE, PHASE, REAL, IMAGINARY)ConvertImage: Boolean indicating if the image was supposed to be convertedDeviceIdentifier: An identifier for the device used to acquire the imageEPIFactor: The echo planar imaging (EPI) factor of the imageEchoTime: The echo time (in ms) of the imageEchoTrainLength: The echo train length of the imageExContrastAgent: Any information about the exogenous contrast agent used in the acquisitionFieldOfView: The field of view (in mm) of the image (list of 2 floats)FlipAngle: The flip angle (in degrees) of the imageImageOrientationPatient: The DICOM image orientation patient tag of the image (list of 6 floats)ImagePositionPatient: The DICOM image position patient tag of the image (list of 3 floats)ImageType: The DICOM image type tag of the image (list of strings)InstitutionName: The institution name of the device used to acquire the imageInversionTime: The inversion time (in ms) of the imageLookupName: Any naming components for this image pulled from the lookup-table (list of strings)MagneticFieldStrength: The magnetic field strength (in T) of the imageManualName: Any naming components for this image pulled from the manual naming entries (list of strings)Manufacturer: The manufacturer of the device used to acquire the imageMultiFrame: Boolean indicating if the image is a multi-frame DICOM imageNiftiCreated: Boolean indicating if the image was successfully converted to NIfTINiftiHash: The hash of the converted NIfTI fileNiftiName: The final filename for the converted NIfTI file.NumFiles: Number of files (or frames) incorporated into the image (number of slices).NumberOfAverages: The number of averages used in the acquisitionPercentSampling: The percent of k-space sampling used in the acquisitionPixelBandwidth: The pixel bandwidth (in Hz) of the imagePredictedName: Automatically generated name prediction from the DICOM metadata (list of strings)ReceiveCoilName: The name of the receive coil used in the acquisitionReconMatrix: The reconstructed in-plane matrix size of the image (list of 2 ints)ReconResolution: The reconstructed, in-plane resolution of the image (list of 2 floats)RepetitionTime: The repetition time (in ms) of the imageScanOptions: Any scan options used in the acquisitionScannerModelName: The model name of the scanner used to acquire the imageSequenceName: The name of the sequence used to acquire the imageSequenceType: The type of sequence used to acquire the imageSequenceVariant: The variant of the sequence used to acquire the imageSeriesDescription: The DICOM series description tag of the imageSeriesNumber: The DICOM series number tag of the imageSeriesUID: The DICOM series UID tag for the imageSliceOrientation: The slice orientation of the image (axial, sagittal, or coronal)SliceSpacing: The slice spacing (in mm) between slices of the imageSliceThickness: The slice thickness (in mm) of the imageSoftwareVersions: The software versions of the device that acquired the imageSourceHash: The hash of the source DICOM filesSourcePath: The path to the source DICOM files (relative to session directory, e.gdcm/...)StudyDescription: The study description DICOM tag for the imageStudyUID: The study UID DICOM tag for the imageTriggerTime: The trigger time (in ms) of the image (can be used to store inversion time)VariableFlipAngle: Boolean indicating if the image used variable flip anglesContainer CreationFor reproducibility, processing must be done in a container.
This can be Docker or Apptainer/Singularity, but requires a few specific labels to be set to maintain strict accounting of the container used.The labels are:ci.timestamp: Timestamp of the container image creation (%Y-%m-%dT%H:%M:%SZ)ci.builder: The username of the builder of the container image (who initiated the build)ci.image: URL of the container image in a repository (e.g. Docker Hub)ci.tag: Version tag of the container imageci.commit: Commit hash of the Dockerfile/repo used to build the container imageci.digest: Digest hash of the container imageThese labels are most easily set by using Continuous Integration (CI) to create your images.
This is an example.gitlab-ci.ymlto achieve this on GitLab:variables:GIT_STRATEGY:cloneGIT_DEPTH:0build:image:docker:20.10.16stage:buildservices:-docker:20.10.16-dindvariables:TAG:$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAMEscript:-docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY-docker build--label ci.timestamp=$(date -u +'%Y-%m-%dT%H:%M:%SZ')--label ci.builder=$GITLAB_USER_LOGIN--label ci.image=$CI_REGISTRY_IMAGE--label ci.tag=$CI_COMMIT_REF_NAME--label ci.commit=$CI_COMMIT_SHA-t $TAG .-DIGEST=$(docker inspect --format='{{index .Id}}' $TAG)-echo "FROM $TAG" | docker buildx build --label ci.digest=$DIGEST -t $TAG --push -only:-tagsUsing a GitHub action is similar and can be done with GitHub Actions:name:Publish Docker Image to GHCRon:push:branches:-'main'tags:-'*'jobs:docker:name:Build and Push Docker Imageruns-on:ubuntu-latestpermissions:packages:writesteps:-name:Get build timeid:build_timerun:echo "time=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"-name:Checkoutuses:actions/checkout@v4with:fetch-depth:0ref:${{ github.ref_name }}-name:Set up Docker Buildxuses:docker/setup-buildx-action@v3with:driver:docker-name:Login to Registryuses:docker/login-action@v3with:registry:ghcr.iousername:${{ github.actor }}password:${{ github.token }}-name:Build imageid:docker_builduses:docker/build-push-action@v5with:context:.load:truelabels:|ci.timestamp=${{ steps.build_time.outputs.time }}ci.image=${{ github.repository }}ci.tag=${{ github.ref_name }}ci.commit=${{ github.sha }}ci.builder=${{ github.triggering_actor }}tags:ghcr.io/${{ github.repository }}:${{ github.ref_name }}build-args:|BUILDKIT_CONTEXT_KEEP_GIT_DIR=true-name:Write new Dockerfilerun:echo "FROM ghcr.io/${{ github.repository }}:${{ github.ref_name }}" > Dockerfile.new-name:Build labeled imageuses:docker/build-push-action@v5with:context:.file:Dockerfile.newpush:truelabels:ci.digest=${{ steps.docker_build.outputs.digest }}tags:ghcr.io/${{ github.repository }}:${{ github.ref_name }}