QIICR / dcmqi

dcmqi (DICOM for Quantitative Imaging) is a free, open source C++ library for conversion between imaging research formats and the standard DICOM representation for image analysis results
https://qiicr.gitbook.io/dcmqi-guide/
BSD 3-Clause "New" or "Revised" License
232 stars 62 forks source link

itkimage2segimage Condition failed: Is a directory in ../../apps/seg/itkimage2segimage.cxx:125 #424

Closed athanell closed 3 years ago

athanell commented 3 years ago

Hello,

I am trying to use the itkimage2segimage to convert a nifti segmentation into a SEG DICOM object. I loaded a DICOM MRI series to ITK snap, created a segmentation and saved it ( binary label segmentation) into the nifti format.

My dir structure is the following:


/home/data/test_dicom/
├── dcm_seg
├── mri_series
│   ├── 1.2.246.352.221.462.dcm
│   ├── 1.2.246.352.221.464.dcm
│   ├── 1.2.246.352.221.465.dcm
│   ├── .....................
│   ├── 1.2.246.352.221.467.dcm
│   
├── nifti_seg
│   └── test_nifti-segmentation.nii.gz
└── schema.json

The schema is

{
  "ContentCreatorName": "JohnDoe",
  "ClinicalTrialSeriesID": "Session1",
  "ClinicalTrialTimePointID": "1",
  "SeriesDescription": "Segmentation",
  "SeriesNumber": "300",
  "InstanceNumber": "300",
  "BodyPartExamined": "Brain",
  "segmentAttributes": [
    [
      {
        "labelID": 1,
        "SegmentDescription": "Brain segmentation",
        "SegmentAlgorithmType": "SEMIAUTOMATIC",
        "SegmentAlgorithmName": "myAlgorithm",
        "SegmentedPropertyCategoryCodeSequence": {
          "CodeValue": "123037004",
          "CodingSchemeDesignator": "SCT",
          "CodeMeaning": "Anatomical Structure"
        },
        "SegmentedPropertyTypeCodeSequence": {
          "CodeValue": "12738006",
          "CodingSchemeDesignator": "SCT",
          "CodeMeaning": "Brain"
        },
        "recommendedDisplayRGBValue": [
          250,
          250,
          225
        ]
      }
    ]
  ],
  "ContentLabel": "SEGMENTATION",
  "ContentDescription": "Image segmentation",
  "ClinicalTrialCoordinatingCenterName": "dcmqi"
}

in the above schema adding the following line didn't change the error you will see below

"@schema": "https://raw.githubusercontent.com/qiicr/dcmqi/master/doc/schemas/seg-schema.json#",

I used the following command:

 ./bin/itkimage2segimage --inputImageList /home/data/test_dicom/nifti_seg/test_nifti-segmentation.nii.gz --inputDICOMDirectory /home/data/test_dicom/mri_series/ --outputDICOM /home/data/test_dicom/dcm_seg/ --inputMetadata /home/data/test_dicom/schema.json 

dcmqi repository URL: git@github.com:QIICR/dcmqi.git revision: 4f66874 tag: latest-2-g4f66874
Searching recursively /home/data/test_dicom/mri_series/ for DICOM files
168 of 168 slices mapped to source DICOM images
Found 2 label(s)
Skipping label 0
Processing label 1
Total non-empty slices that will be encoded in SEG for label 1 is 168
 (inclusive from 0 to 168)
Condition failed: Is a directory in ../../apps/seg/itkimage2segimage.cxx:125
Fatal error encountered.

Any ideas on what might be going wrong?

Thank you

lorteddie commented 3 years ago

I think parameter outputDICOM should be a filename not a directory.

athanell commented 3 years ago

@lorteddie thanks for detecting that! Indeed, I wrongly used a directory name instead of a dcm segmentation file