ITK
ITK copied to clipboard
Inconsistent read from `.mha` vector image
Description
Behavior is observed where vector pixel data is read inconsistently from a small .mha data file.
Steps to Reproduce
- Download the data file from the ITKUltrasound data folder on Girder: rf_voltage_15_freq_0005000000_2017-5-31_12-36-44_ReferenceSpectrum_side_lines_03_fft1d_size_128.mha. The data file is a 3D image with a single voxel that is a 31-channel vector.
- Repeatedly read in the 31-channel vector image in Python and access the 29th or 30th channel
>>> import itk
>>> pixel_type = itk.VariableLengthVector[itk.F]
>>> image = itk.imread(r'path/to/rf_voltage_15_freq_0005000000_2017-5-31_12-36-44_ReferenceSpectrum_side_lines_03_fft1d_size_128.mha',pixel_type=pixel_type)
>>> image.GetPixel(0).GetElement(29)
1.2316740878152266e-39
>>> image = itk.imread(r'path/to/rf_voltage_15_freq_0005000000_2017-5-31_12-36-44_ReferenceSpectrum_side_lines_03_fft1d_size_128.mha',pixel_type=pixel_type)
>>> image.GetPixel(0).GetElement(29)
1.6303663969778794e+20
>>> image = itk.imread(r'path/to/rf_voltage_15_freq_0005000000_2017-5-31_12-36-44_ReferenceSpectrum_side_lines_03_fft1d_size_128.mha',pixel_type=pixel_type)
>>> image.GetPixel(0).GetElement(29)
1.6303663969778794e+20
>>> image = itk.imread(r'path/to/rf_voltage_15_freq_0005000000_2017-5-31_12-36-44_ReferenceSpectrum_side_lines_03_fft1d_size_128.mha',pixel_type=pixel_type)
>>> image.GetPixel(0).GetElement(29)
1.2316740878152266e-39
Expected behavior
Pixel output value is consistent
Actual behavior
Channel 29 alternates between 1.2316740878152266e-39 and 1.6303663969778794e+20
Channel 30 alternates between 2.1019476964872256e-44 and 0.15648820996284485
Reproducibility
Alternates evenly, approximately 50%
Versions
ITK 5.3rc03
Environment
Windows, Python 3.8.5
Additional Information
Hi @aylward @jjomier, do either of you perhaps have thoughts on how best to investigate this issue with reading from a MetaImage file?
@aylward let me know if I should investigate this. Looks like either the writing or reading of the file is incorrect (haven't tested C++)
Weird!
I'm interested in where this inconsistency may be introduced.
- Try converting the file to .nii and see if the problem persists.
- Try converting the image to an array (and/or an array view) and see if the problem persists
- Try using an uncompressed metaimage...and see if the problem persists.
- Read it into a different variable every time (instead of overwriting image every time)...and see if the problem persists
I think that covers most of the points in the pipeline that could be introducing this bad behavior.
Thanks for finding this!!!
s