Skip to content

Commit c380670

Browse files
blowekampdzenanz
authored andcommitted
BUG: Fix MRC zero spacing for tilt series
MRC image collected as a tilt series had spacing being computed a zero. This causes the image to be unreadable but ITK. Set the spacing to 1 in the case.
1 parent d96191b commit c380670

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

Modules/IO/MRC/src/itkMRCImageIO.cxx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -200,20 +200,10 @@ MRCImageIO::ReadImageInformation()
200200
}
201201
}
202202

203-
if (header.xlen == 0.0f && header.ylen == 0.0f && header.zlen == 0.0f)
204-
{
205-
// if the spacing was not set in the header then this is the
206-
// default
207-
m_Spacing[0] = 1.0;
208-
m_Spacing[1] = 1.0;
209-
m_Spacing[2] = 1.0;
210-
}
211-
else
212-
{
213-
m_Spacing[0] = header.xlen / static_cast<float>(header.mx);
214-
m_Spacing[1] = header.ylen / static_cast<float>(header.my);
215-
m_Spacing[2] = header.zlen / static_cast<float>(header.mz);
216-
}
203+
// if the spacing was not set in the header then 1.0 is the default
204+
m_Spacing[0] = header.xlen != 0.0f ? header.xlen / static_cast<float>(header.mx) : 1.0;
205+
m_Spacing[1] = header.ylen != 0.0f ? header.ylen / static_cast<float>(header.my) : 1.0;
206+
m_Spacing[2] = header.zlen != 0.0f ? header.zlen / static_cast<float>(header.mz) : 1.0;
217207

218208
// copy the origin
219209
m_Origin[0] = header.xorg;

Modules/IO/MRC/test/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,11 @@ itk_add_test(NAME itkMRCImageIOTest2c
3434
DATA{${ITK_DATA_ROOT}/Input/RGBTestImageLZW.tif}
3535
${ITK_TEST_OUTPUT_DIR}/itkMRCImageIOTest2c.mrc
3636
38a2dcfc08812e04b1528f15ca3d2ab7)
37+
itk_add_test(NAME itkMRCImageIOTest2d
38+
COMMAND ITKIOMRCTestDriver
39+
--compare-MD5 ${ITK_TEST_OUTPUT_DIR}/itkMRCImageIOTest2d.mrc
40+
96093c8573ce2b4f197f0b0bfcc574bf
41+
itkMRCImageIOTest2
42+
DATA{Input/tilt_uint8.mrc}
43+
${ITK_TEST_OUTPUT_DIR}/itkMRCImageIOTest2d.mrc
44+
96093c8573ce2b4f197f0b0bfcc574bf)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
332985f125b8584b9ba158faef6294cd2f2a9e8d9fb5b7f05a74b08089b2d4e13465c1c483e42b6c4263dac9af19542a8bd5ff33dc627507ba60c976a3cb5b0a

0 commit comments

Comments
 (0)