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

Metadata partly deleted when writing .ISQ #70

Open
fnuggel opened this issue Jan 19, 2023 · 3 comments
Open

Metadata partly deleted when writing .ISQ #70

fnuggel opened this issue Jan 19, 2023 · 3 comments

Comments

@fnuggel
Copy link

fnuggel commented Jan 19, 2023

Hi,

i noticed that when opening an .ISQ file and then writing it as an .ISQ file, parts of the metadata seem to get deleted, or changed.
It seems to be affecting the CalibrationData, CreationDate, ModificationDate, MuScaling, MuWater, RescaleIntercept, RescaleSlope, RescaleType and RescaleUnits.

Here is an example of the code:

import itk
image=itk.imread('original_file.ISQ')
print(dict(image))
itk.imwrite(image,'saved_file.ISQ')
image_saved=itk.imread('saved_file.ISQ')
print(dict(image_saved))

Output for the original file:

{'CalibrationData': '60 kVp, BH: 200 mg HA/ccm, Scaling 8192', 'CreationDate': '14-JUN-2021 13:27:50.972', 'DataRange': (-5135.0, 11000.0), 'Energy': 59.4, 'Intensity': 0.9, 'MeasurementIndex': 24945, 'ModificationDate': '14-JUN-2021 13:27:50.972', 'MuScaling': 8192.0, 'MuWater': 0.2402999997138977, 'NumberOfProjections': 750, 'NumberOfSamples': 1536, 'PatientIndex': 3453, 'PatientName': 'Anonymous', 'ReconstructionAlg': 3, 'ReferenceLine': 0.0, 'RescaleIntercept': -1000.0, 'RescaleSlope': 0.5079913135469725, 'RescaleType': 2, 'RescaleUnits': 'mg HA/ccm', 'SampleTime': 100.0, 'ScanDistance': 125.952, 'ScannerID': 3333, 'ScannerType': 9, 'Site': 39, 'SliceIncrement': 0.08199999999999999, 'SliceThickness': 0.08199999999999999, 'Version': 'CTDATA-HEADER_V1', 'origin': array([0., 0., 0.]), 'spacing': array([0.082, 0.082, 0.082]), 'direction': array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])}

Output for the written file:

{'CalibrationData':` '', 'CreationDate': '6-DEC-1911 13:07:54.671', 'DataRange': (-5135.0, 11000.0), 'Energy': 59.4, 'Intensity': 0.9, 'MeasurementIndex': 24945, 'ModificationDate': '6-DEC-1911 13:07:54.671', 'MuScaling': 1.0, 'MuWater': 0.7032999992370605, 'NumberOfProjections': 750, 'NumberOfSamples': 1536, 'PatientIndex': 3453, 'PatientName': 'Anonymous', 'ReconstructionAlg': 3, 'ReferenceLine': 0.0, 'RescaleIntercept': 0.0, 'RescaleSlope': 1.0, 'RescaleType': 0, 'RescaleUnits': '', 'SampleTime': 100.0, 'ScanDistance': 125.952, 'ScannerID': 3333, 'ScannerType': 9, 'Site': 39, 'SliceIncrement': 0.08199999999999999, 'SliceThickness': 0.08199999999999999, 'Version': 'CTDATA-HEADER_V1', 'origin': array([0., 0., 0.]), 'spacing': array([0.082, 0.082, 0.082]), 'direction': array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]])}

Is there maybe a solution for this?

Thanks for any help in advance and thanks for providing this tool!

@dzenanz
Copy link
Member

dzenanz commented Jan 19, 2023

I guess this piece of code should not set header to all zeroes, but utilize more metadata to write into that header. I don't have a specification of ISQ. @mkuczyns do you know what is going on?

@mkuczyns
Copy link
Collaborator

It looks like not all of the metadata is written to the ISQ header (e.g., CalibrationData, etc.), but is filled with zeros instead. Other values like Mu_Scaling are modified to prevent rescaling to HU if read in again. The WriteISQHeader function will need to be updated to populate the ISQ header correctly. In the cases where we don't have metadata to populate the ISQ header, we can initialize the CalibrationData variable to something the Scanco system recognizes and leave it up to the user to change this if needed. For example, we can just set CalibrationData = "60 kVp, BH: 200 mg HA/ccm, Scaling 8192".

One other issue I notice is with the Mu_Scaling variable being set to 1 after reading in a Scanco file and rescaling to HU. While this works fine, it's not ideal when trying to use these files on the Scanco system. I would propose we rescale back to native Scanco units on writing ISQ, provided that the Mu_Scaling, Rescale_Slope, Rescale_Intercept, and Mu_Water variables are valid (i.e., not 0 or 1). Otherwise we can skip rescaling and just write out the ISQ.

I can try to fix these issues over the coming days.

@dzenanz
Copy link
Member

dzenanz commented Jan 23, 2023

I can try to fix these issues over the coming days.

That would be great!

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