rordenlab / dcm2niix

dcm2nii DICOM to NIfTI converter: compiled versions available from NITRC
https://www.nitrc.org/plugins/mwiki/index.php/dcm2nii:MainPage
Other
890 stars 228 forks source link

No slice-timing JSON output with Siemens scanner #309

Closed Brainarea closed 5 years ago

Brainarea commented 5 years ago

This is the output given by DCM2niix.

{
    "Modality": "MR",
    "MagneticFieldStrength": 3,
    "ImagingFrequency": 123.293,
    "Manufacturer": "Siemens",
    "ManufacturersModelName": "Allegra",
    "InstitutionName": "",
    "InstitutionAddress": "",
    "DeviceSerialNumber": "20120",
    "StationName": "mrc20120",
    "PatientPosition": "HFS",
    "ProcedureStepDescription": "",
    "SoftwareVersions": "syngo_MR_2004A_4VA25A",
    "MRAcquisitionType": "2D",
    "SeriesDescription": "ep2d_REST_O_open",
    "ProtocolName": "ep2d_REST_O_open",
    "ScanningSequence": "SE_EP",
    "SequenceVariant": "SK",
    "ScanOptions": "FS",
    "SequenceName": "epfid2d1_128",
    "ImageType": ["ORIGINAL", "PRIMARY", "M", "ND", "MOSAIC"],
    "SeriesNumber": 3,
    "AcquisitionTime": "10:49:26.507490",
    "AcquisitionNumber": 1,
    "SliceThickness": 2.5,
    "SpacingBetweenSlices": 2.5,
    "SAR": 0.0264227,
    "EchoTime": 0.023,
    "RepetitionTime": 3,
    "FlipAngle": 84,
    "PartialFourier": 0.75,
    "BaseResolution": 128,
    "ShimSetting": [
        -13,
        46,
        27,
        -29,
        160,
        -124,
        29,
        -92 ],
    "TxRefAmp": 156.349,
    "PhaseResolution": 1,
    "ReceiveCoilName": "Head_3T",
    "PulseSequenceDetails": "%SiemensSeq%_ep2d_pace",
    "PercentPhaseFOV": 100,
    "PhaseEncodingSteps": 96,
    "AcquisitionMatrixPE": 128,
    "ReconMatrixPE": 128,
    "PixelBandwidth": 2605,
    "PhaseEncodingDirection": "j-",
    "ImageOrientationPatientDICOM": [
        1,
        0,
        0,
        0,
        1,
        0   ],
    "InPlanePhaseEncodingDirectionDICOM": "COL",
    "ConversionSoftware": "dcm2niix",
    "ConversionSoftwareVersion": "v1.0.20190410  Clang4.0.1"
}
neurolabusc commented 5 years ago

Your data was acquired with A25 software circa 2004 (syngo_MR_2004A_4VA25A). The tag MosaicRefAcqTimes was introduced much later with B15. This reflects a limitation with your images, not dcm2niix.

While the Allegra provided state-of-the-art hardware for its day, it saw limited production, so the software saw less development than for the Trio (which at least initially had inferior gradients). I think it is very unlikely, but it is possible that slice timing was back-ported to Allegra's that were unable to upgrade with the contemporary Trios. One way to check the contents of the your CSA header is to run dcm2niix with logorrheic verbosity ("-v 2"). You might want to convert just a single volume of your EPI data with this mode, as the output can be overwhelming. This would reveal both the presence of a CSA header (0029,1009) and within the header it would reveal a field "MosaicRefAcqTimes":

 0028,0107 2@2714 US 2362 
 0028,1050 4@2724 DS  763
 0028,1051 4@2736 DS  1639
 0028,1055 6@2748 LO  Algo1
 0029,0010 18@2762 LO  SIEMENS_CSA_HEADER
 0029,0011 22@2788 LO  SIEMENS_MEDCOM_HEADER2
 0029,1008 12@2818 CS  IMAGE_NUM_4
 0029,1009 8@2838 LO  20140310
   100 CSA of EchoLinePosition 6
...
   9632 CSA of MosaicRefAcqTimes 36
   sliceTimes 0 70  142.5   215 285 357.5   430 500 572.5   645 715 787.5   860 932.5   1002.5  1075    1147.5  1217.5  1290    1362.5  1432.5  1505    1577.5  1647.5  1720    1792.5  1862.5  1935    2007.5  2077.5  2150    2222.5  2295    2365    2437.5  
...
Brainarea commented 5 years ago

Thanks for the quick reply. It's apparently not there :'(

0029,0010 18@2258 LO  SIEMENS_CSA_HEADER
 0029,0011 22@2284 LO  SIEMENS_MEDCOM_HEADER
 0029,0012 22@2314 LO  SIEMENS_MEDCOM_HEADER2
 0029,1008 12@2344 CS  IMAGE_NUM_4
 0029,1009 8@2364 LO  20150430
   100 CSA of EchoLinePosition 6
   292 CSA of EchoColumnPosition 6
   484 CSA of EchoPartitionPosition 6
   676 CSA of UsedChannelMask 6
   868 CSA of Actual3DImaPartNumber 0
   952 CSA of ICE_Dims 6
   1164 CSA of B_value 0
   1248 CSA of Filter1 0
   1332 CSA of Filter2 0
   1416 CSA of ProtocolSliceNumber 6
   1608 CSA of RealDwellTime 6
   1800 CSA of PixelFile 0
   1884 CSA of PixelFileName 0
   1968 CSA of SliceMeasurementDuration 6
   2160 CSA of SequenceMask 6
   2352 CSA of AcquisitionMatrixText 6
   2544 CSA of MeasuredFourierLines 6
   2736 CSA of FlowEncodingDirection 6
   2928 CSA of FlowVenc 6
   3120 CSA of PhaseEncodingDirectionPositive 6
   3312 CSA of NumberOfImagesInMosaic 6
   3504 CSA of DiffusionGradientDirection 0
   3588 CSA of ImageGroup 6
   3780 CSA of SliceNormalVector 6
   SliceNormalVector 0.000000 0.000000 1.000000
   3996 CSA of DiffusionDirectionality 0
   4080 CSA of TimeAfterStart 6
   4272 CSA of FlipAngle 0
   4356 CSA of SequenceName 0
   4440 CSA of RepetitionTime 0
   4524 CSA of EchoTime 0
   4608 CSA of NumberOfAverages 0
   4692 CSA of VoxelThickness 0
   4776 CSA of VoxelPhaseFOV 0
   4860 CSA of VoxelReadoutFOV 0
   4944 CSA of VoxelPositionSag 0
   5028 CSA of VoxelPositionCor 0
   5112 CSA of VoxelPositionTra 0
   5196 CSA of VoxelNormalSag 0
   5280 CSA of VoxelNormalCor 0
   5364 CSA of VoxelNormalTra 0
   5448 CSA of VoxelInPlaneRot 0
   5532 CSA of ImagePositionPatient 0
   5616 CSA of ImageOrientationPatient 0
   5700 CSA of PixelSpacing 0
   5784 CSA of SliceLocation 0
   5868 CSA of SliceThickness 0
   5952 CSA of SpectrumTextRegionLabel 0
   6036 CSA of Comp_Algorithm 0
   6120 CSA of Comp_Blended 0
   6204 CSA of Comp_ManualAdjusted 0
   6288 CSA of Comp_AutoParam 0
   6372 CSA of Comp_AdjustedParam 0
   6456 CSA of Comp_JobID 0
   6540 CSA of FMRIStimulInfo 6
   6732 CSA of FlowEncodingDirectionString 0
   6816 CSA of RepetitionTimeEffective 0
 0029,1010 6820@2384 OB <6820 bytes> 
 0029,1018 2@9212 CS  MR
 0029,1019 8@9222 LO  20150430
 0029,1020 53420@9242 OB <53420 bytes> 
 0029,1131 14@62670 LO  33.0.276826382
 0029,1132 4@62692 UL 1605632 
 0029,1133 4@62704 UL 0 
 0029,1134 12@62716 CS  DB_TO_DICOM
 0029,1260 4@62736 LO  com
neurolabusc commented 5 years ago

dicm2nii uses additional methods to determine Siemens Slice Timing

neurolabusc commented 5 years ago

If you compile from the developmental branch, dcm2niix now clones dicm2nii's method for extracting slice times from ucMode. I would be grateful if you could test this thoroughly: I only have access to a single Siemens B12 dataset for testing.

If you have access to this system, it would terrific to have a validation dataset acquired (e.g. just a few volumes each of a low resolution fMRI sequence acquired with ascending, descending and interleaved slice order). I would also be interested in seeing a dataset where the mosaic slice order is set to H>>F. While this is an extremely rare setting, I am not precisely sure if my current solution handles the spatial transform correctly.

Brainarea commented 5 years ago

Thanks a lot for taking the time to work of this. I have very limited access to our MRI system but i'll ask if the person in charge could create that validation dataset. I tried the development branch on my data, unfortunately it gave me the same result:

{
    "Modality": "MR",
    "MagneticFieldStrength": 3,
    "ImagingFrequency": 123.293,
    "Manufacturer": "Siemens",
    "ManufacturersModelName": "Allegra",
    "InstitutionName": "",
    "InstitutionAddress": "",
    "DeviceSerialNumber": "20120",
    "StationName": "mrc20120",
    "PatientPosition": "HFS",
    "ProcedureStepDescription": "",
    "SoftwareVersions": "syngo_MR_2004A_4VA25A",
    "MRAcquisitionType": "2D",
    "SeriesDescription": "ep2d_REST_O_open",
    "ProtocolName": "ep2d_REST_O_open",
    "ScanningSequence": "SE_EP",
    "SequenceVariant": "SK",
    "ScanOptions": "FS",
    "SequenceName": "epfid2d1_128",
    "ImageType": ["ORIGINAL", "PRIMARY", "M", "ND", "MOSAIC"],
    "SeriesNumber": 3,
    "AcquisitionTime": "10:49:26.507490",
    "AcquisitionNumber": 1,
    "SliceThickness": 2.5,
    "SpacingBetweenSlices": 2.5,
    "SAR": 0.0264227,
    "EchoTime": 0.023,
    "RepetitionTime": 3,
    "FlipAngle": 84,
    "PartialFourier": 0.75,
    "BaseResolution": 128,
    "ShimSetting": [
        -13,
        46,
        27,
        -29,
        160,
        -124,
        29,
        -92 ],
    "TxRefAmp": 156.349,
    "PhaseResolution": 1,
    "ReceiveCoilName": "Head_3T",
    "PulseSequenceDetails": "%SiemensSeq%_ep2d_pace",
    "PercentPhaseFOV": 100,
    "PhaseEncodingSteps": 96,
    "AcquisitionMatrixPE": 128,
    "ReconMatrixPE": 128,
    "PixelBandwidth": 2605,
    "PhaseEncodingDirection": "j-",
    "ImageOrientationPatientDICOM": [
        1,
        0,
        0,
        0,
        1,
        0   ],
    "InPlanePhaseEncodingDirectionDICOM": "COL",
    "ConversionSoftware": "dcm2niix",
    "ConversionSoftwareVersion": "v1.0.20190410  Clang9.0.0"
}
neurolabusc commented 5 years ago

You are not running the developmental branch version - it will report v1.0.20190707 instead of v1.0.20190410. On Unix systems, you can build the developmental branch with these commands:

git clone --branch development https://github.com/rordenlab/dcm2niix.git
cd dcm2niix
mkdir build && cd build
cmake -DZLIB_IMPLEMENTATION=Cloudflare -DUSE_JPEGLS=ON -DUSE_OPENJPEG=ON ..
make

This will create a new executable in the folder /dcm2niix/build/bin. You can copy this to your path if you want to use this version exclusively.

Brainarea commented 5 years ago

I indeed forgot the --branch term so i was working with the master in a folder named development... Anyway, re-did it with the proper version, result remains the same though:

{
    "Modality": "MR",
    "MagneticFieldStrength": 3,
    "ImagingFrequency": 123.293,
    "Manufacturer": "Siemens",
    "ManufacturersModelName": "Allegra",
    "InstitutionName": "UAB",
    "InstitutionAddress": "",
    "DeviceSerialNumber": "20120",
    "StationName": "mrc20120",
    "PatientPosition": "HFS",
    "ProcedureStepDescription": "",
    "SoftwareVersions": "syngo_MR_2004A_4VA25A",
    "MRAcquisitionType": "2D",
    "SeriesDescription": "ep2d_REST_O_open",
    "ProtocolName": "ep2d_REST_O_open",
    "ScanningSequence": "SE_EP",
    "SequenceVariant": "SK",
    "ScanOptions": "FS",
    "SequenceName": "epfid2d1_128",
    "ImageType": ["ORIGINAL", "PRIMARY", "M", "ND", "MOSAIC"],
    "SeriesNumber": 3,
    "AcquisitionTime": "10:49:26.507490",
    "AcquisitionNumber": 1,
    "SliceThickness": 2.5,
    "SpacingBetweenSlices": 2.5,
    "SAR": 0.0264227,
    "EchoTime": 0.023,
    "RepetitionTime": 3,
    "FlipAngle": 84,
    "PartialFourier": 0.75,
    "BaseResolution": 128,
    "ShimSetting": [
        -13,
        46,
        27,
        -29,
        160,
        -124,
        29,
        -92 ],
    "TxRefAmp": 156.349,
    "PhaseResolution": 1,
    "ReceiveCoilName": "Head_3T",
    "PulseSequenceDetails": "%SiemensSeq%_ep2d_pace",
    "PercentPhaseFOV": 100,
    "PhaseEncodingSteps": 96,
    "AcquisitionMatrixPE": 128,
    "ReconMatrixPE": 128,
    "PixelBandwidth": 2605,
    "PhaseEncodingDirection": "j-",
    "ImageOrientationPatientDICOM": [
        1,
        0,
        0,
        0,
        1,
        0   ],
    "InPlanePhaseEncodingDirectionDICOM": "COL",
    "ConversionSoftware": "dcm2niix",
    "ConversionSoftwareVersion": "v1.0.20190707  (JP2:OpenJPEG) (JP-LS:CharLS) Clang9.0.0"
}
neurolabusc commented 5 years ago

Can you send me a few volumes - send a dropbox invitation to my email (shown in my avatar). I was able to test the code on B12 but have no examples of A25.

Brainarea commented 5 years ago

Just sent you a box link.

Brainarea commented 5 years ago

Last development worked ! Thanks a lot for making those changes in such a short time! We are working on a Prisma now but many of our studies still have subjects who were scanned on that old Allegra.

neurolabusc commented 5 years ago

I added examples from B12 and B13 that do not include "MosaicRefAcqTimes" but where one can infer slice times from "sSliceArray.ucMode". If you have sample datasts (e.g. phantoms) that you can share from your A-series equipment, it would be great to include them. It is hard to feel confident that this is a robust solution. Test extensively and report any unusual behavior.