Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TotalReadoutTime output in the json file can be inf, which is not allowed by JSON syntax #512

Closed
function2-llx opened this issue May 31, 2021 · 7 comments

Comments

@function2-llx
Copy link

function2-llx commented May 31, 2021

Describe the bug
TotalReadoutTime output in the json file can be inf, which is not allowed by JSON syntax

To Reproduce
Simply run dcm2niix in command line like: dcm2niix -z y -f %s -o <output_dir> <input_dir>
Sorry that I can't provide the specific files to reproduce, but I can upload an screenshot in vscode:
image

Expected behavior
Output a json file that could be parsed by common json library.

Versions

  • dcm2niix version string
    Chris Rorden's dcm2niiX version v1.0.20210317 GCC8.4.0 x86-64 (64-bit Linux)
  • Is this the latest stable release?
    Yes, it is.
  • If the latest stable version fails, and you are using macOS or Linux. Does the latest commit on the development branch resolve your issue? You can build this using the recipe below:
    There's no new commit since the latest release was built.
@neurolabusc
Copy link
Collaborator

neurolabusc commented May 31, 2021

  • There have been numerous commits since the last stable release. Can you test whether the latest commit on the development branch (v1.0.20210426) resolves your issue?
  • Can you include the entire JSON file instead of a partial screenshot, which will reveal further details like the manufacturer.

@function2-llx
Copy link
Author

My fault,I only checked the master branch.

I've build dcm2niix myself with commit 7038255 (the HEAD for development branch currently), however it still not work for me.

Generated JSON:

{
	"Modality": "MR",
	"MagneticFieldStrength": 30000,
	"Manufacturer": "GE",
	"InternalPulseSequenceName": "EPI2",
	"ManufacturersModelName": "GENESIS_SIGNA",
	"InstitutionName": "Tiantan Hospital",
	"DeviceSerialNumber": "000082427040020",
	"StationName": "GEMSlx3T",
	"PatientPosition": "HFS",
	"SoftwareVersions": "09",
	"MRAcquisitionType": "2D",
	"SeriesDescription": "diffusion  ",
	"ProtocolName": "diffusion  ",
	"ScanningSequence": "EP\\SE",
	"SequenceVariant": "NONE",
	"ScanOptions": "EPI_GEMS\\PFF",
	"ImageType": ["ORIGINAL", "PRIMARY", "OTHER"],
	"SeriesNumber": 4,
	"AcquisitionTime": "09:19:39.000000",
	"SliceThickness": 5,
	"SpacingBetweenSlices": 5,
	"SAR": 0.00807,
	"EchoTime": 0.0734,
	"RepetitionTime": 10,
	"FlipAngle": 90,
	"CoilString": "HEAD",
	"PercentPhaseFOV": 100,
	"PercentSampling": 100,
	"AcquisitionMatrixPE": 128,
	"ReconMatrixPE": 256,
	"TotalReadoutTime": inf,
	"PixelBandwidth": 773.438,
	"PhaseEncodingAxis": "j",
	"ImageOrientationPatientDICOM": [
		1,
		0,
		0,
		0,
		1,
		0	],
	"InPlanePhaseEncodingDirectionDICOM": "COL",
	"ConversionSoftware": "dcm2niix",
	"ConversionSoftwareVersion": "v1.0.20210426"
}

@neurolabusc
Copy link
Collaborator

@function2-llx I think you want to check the provenance of these images. I suspect that some anonymization tool or PACS has corrupted your DICOM images. I suspect if you can get the raw data from your scanner, you will get sensible results. The reasons I am suspicious of these images are:

  1. "MagneticFieldStrength": 30000 should presumably be 3, as units of (0018,0087) is in Tesla
  2. "SoftwareVersions": "09", does not look valid. For GE one would expect something like 28\\LX\\MR29.1_EA_2039.g
  3. The report of PhaseEncodingAxis instead of PhaseEncodingDirection suggests issues with the Protocol Data Block.

While we can certainly put conditionals to avoid reporting non-finite values, I think this is a symptom that your DICOMs have been tampered with.

@function2-llx
Copy link
Author

@neurolabusc Thank you so much for pointing this out! I'll check my DICOM data later.
Seems it's a common issue that JSON cannot encode Infinity of NaN properly, and many projects are facing this. Trivial solution might be:

  • use null
  • use string version of "Infinity" and "NaN"

And one thing notably that python's json library can parse something like:

{
    "a": Infinity,
    "b": NaN
}

to

{'a': inf, 'b': nan}

So this might also be an option (at least for python users).

@neurolabusc
Copy link
Collaborator

The latest commit to the development branch (v1.0.20210531) will only report TotalReadoutTime if finite. Fixes symptom, but not underlying issues with this dataset. Obviously, non-finite TotalReadoutTime suggests the DICOM does not provide valid values for calculation.

@mr-jaemin
Copy link
Collaborator

From the TotalReadoutTime formula below:

TotalReadoutTime = ( ( ceil ((1/Round_factor) * PE_AcquisitionMatrix / Asset_R_factor ) * Round_factor) - 1 ] * EchoSpacing * 0.000001

I suspect that Asset_R_factor was set to 0 (d.accelFactPE = 0.0), perhaps in the absence of DICOM tag (0043,1083) kAssetRFactorsGE. "GENESIS_SIGNA" is an old system.

@function2-llx, could you please check the DICOM tag (0043,1083)? I was expecting [1\1] like below for ASSET=1 dataset

dcmdump DTI/*.MRDC.1 | grep 0043,1083
(0043,1083) DS [1\1]                                    #   4, 2 AssetRFactors

@neurolabusc, Perhaps we can assume d.accelFactPE=1 in case of d.accelFactPE = 0, and can report TotalReadoutTime as long as EchoSpacing > 0

@function2-llx
Copy link
Author

function2-llx commented Jun 1, 2021

@function2-llx, could you please check the DICOM tag (0043,1083)? I was expecting [1\1] like below for ASSET=1 dataset

@mr-jaemin Sure, but I'll have to do it a few days later for some reason. Feel free to remind me if I don't response for a long time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants