PyMAIA_convert_semantic_to_instance_segmentation script#

Script to convert a semantic segmentation dataset (with the Patient ID as the folder name) into an instance segmentation dataset. Instance segmentation masks are saved within the same patient folder with the standard format “INST_SEG.nii.gz”. Regions in instance segmentation containing less than 10 voxels are ignored and the number of labels in each instance segmentation mask is saved in a separate json file (‘inst_seg_labels.json’) alongside its ‘Patient ID’.

usage: PyMAIA_convert_semantic_to_instance_segmentation [-h] --data-folder
                                                        DATA_FOLDER
                                                        --sem-seg-suffix
                                                        SEM_SEG_SUFFIX
                                                        --inst-seg-suffix
                                                        INST_SEG_SUFFIX
                                                        [--inst-seg-folder INST_SEG_FOLDER]
                                                        --output-json-path
                                                        OUTPUT_JSON_PATH
                                                        [--decathlon-format DECATHLON_FORMAT]
                                                        [-v | -q]

Named Arguments#

--data-folder

AutoPET patient dataset folder.

--sem-seg-suffix

Semantic Segmentation suffix.

--inst-seg-suffix

Instance Segmentation suffix.

--inst-seg-folder

Instance Segmentation Folder.Required only for the Decathlon-format Dataset.

--output-json-path

Output path of json file.

--decathlon-format

Flag to specify if the Dataset is in the Decathlon format.

Default: no

-v, --verbose

Enable verbose output in terminal. Add multiple times to increase verbosity.

-q, --silent

Suppress most log outputs in terminal.

Example call:

PyMAIA_convert_semantic_to_instance_segmentation  --data-folder /PATH/TO/SEMANTIC_SEG_DATA --sem-seg-suffix _SEG.nii.gz --inst-seg-suffix _INST_SEG.nii.gz --output-json-path /PATH/TO/JSON/inst_seg_labels.json