I'm getting what appears to be a cropped binary image following use of Transformix. I would appreciate some insight as to whether the effect is some artefact due to improper use, an error in my interpretation, or other.
I begin with a DICOM SEG that relates to a "Source" 3D DICOM image, SrcIm. The objective is to resample the Source 3D segment to a "Target" 3D DICOM image's (TrgIm) grid. The SEG is parsed to obtain a Numpy pixel array, SrcPixArr and based on the ReferencedSOPInstanceUIDs, a list of indices, SrcF2Sinds (frame-to-slice indices), that link each frame in SrcPixArr to the slice number within SrcIm.
SrcPixArr has shape (F, R, C), where F = the number of frames that make up the segment, R/C = the number of rows/cols of SrcIm.
Next I convert SrcPixArr to what I call a "labelmap array", which is simply a zero-padded representation of SrcPixArr. SrcLabmapArr has shape (S, R, C), where S = the number of slices in SrcIm. The indices SrcF2Sinds determine where the F 2D masks are mapped to within the S frames in SrcLabmapArr.
Now that I have a pixel array that matches the dimensions of SrcIm, I convert SrcLabmapArr to a SimpleITK image. I call this a "labelmap image" - not to be confused with ITK's Labelmap class. SrcLabmapIm not only has the same size, but also origin, spacing and direction as SrcIm.
I register SrcIm (= moving image) toTrgIm (= fixed image), then use Transformix to transform SrcLabmapIm to get TxSrcLabmapIm.
I can provide the code used to perform the above, but in the interest of keeping this readable I have only copied the bits that I suspect are relevant to ascertain what's the cause of the cropping.
TxImFilt = sitk.TransformixImageFilter()
TxImFilt.SetMovingImage(SrcLabmapIm)
TxParamMap = RegImFilt.GetParameterMap()
TxMap = RegImFilt.GetTransformParameterMap()
""" See [1]: """
TxMap[0]["ResampleInterpolator"] = ["FinalNearestNeighborInterpolator"]
""" The image is binary so set the FinalBSplineInterpolationOrder to 0 to avoid "overshoot"-related
"garbage" as described in the elastix manual (see 4.3 The transform parameter file): """
TxMap[0]["FinalBSplineInterpolationOrder"] = ["0"]
TxImFilt.SetTransformParameterMap(TxMap)
TxImFilt.Execute()
TxSrcLabmapIm = TxImFilt.GetResultImage()
[1] As per @NHPatterson 's advice #409
I've uploaded a jpg of a plot of the segmentations present for Source (spanning slices 108 to 122), and the transformed segmentations for Target (spanning slices 19 to 25).
If it's of any use, here I have put some NIFTI files of SrcIm, TrgIm, SrcLabmapIm and TxSrcLabmapIm (ignore the "New" part of the filename), as well as the source SEG, and folders containing the Source and Target DICOMs. Thanks!
Hello,
I'm getting what appears to be a cropped binary image following use of Transformix. I would appreciate some insight as to whether the effect is some artefact due to improper use, an error in my interpretation, or other.
I begin with a DICOM SEG that relates to a "Source" 3D DICOM image,
SrcIm
. The objective is to resample the Source 3D segment to a "Target" 3D DICOM image's (TrgIm
) grid. The SEG is parsed to obtain a Numpy pixel array,SrcPixArr
and based on the ReferencedSOPInstanceUIDs, a list of indices,SrcF2Sinds
(frame-to-slice indices), that link each frame inSrcPixArr
to the slice number withinSrcIm
.SrcPixArr
has shape(F, R, C)
, whereF
= the number of frames that make up the segment,R
/C
= the number of rows/cols ofSrcIm
.Next I convert
SrcPixArr
to what I call a "labelmap array", which is simply a zero-padded representation ofSrcPixArr
.SrcLabmapArr
has shape(S, R, C)
, whereS
= the number of slices inSrcIm
. The indicesSrcF2Sinds
determine where theF
2D masks are mapped to within theS
frames inSrcLabmapArr
.Now that I have a pixel array that matches the dimensions of
SrcIm
, I convertSrcLabmapArr
to a SimpleITK image. I call this a "labelmap image" - not to be confused with ITK's Labelmap class.SrcLabmapIm
not only has the same size, but also origin, spacing and direction asSrcIm
.I register
SrcIm
(= moving image) toTrgIm
(= fixed image), then use Transformix to transformSrcLabmapIm
to getTxSrcLabmapIm
.I can provide the code used to perform the above, but in the interest of keeping this readable I have only copied the bits that I suspect are relevant to ascertain what's the cause of the cropping.
Following is how I perform the registration:
And the transformation of
SrcLabmapIm
:[1] As per @NHPatterson 's advice #409
I've uploaded a jpg of a plot of the segmentations present for Source (spanning slices 108 to 122), and the transformed segmentations for Target (spanning slices 19 to 25).
If it's of any use, here I have put some NIFTI files of
SrcIm
,TrgIm
,SrcLabmapIm
andTxSrcLabmapIm
(ignore the "New" part of the filename), as well as the source SEG, and folders containing the Source and Target DICOMs. Thanks!print(SrcIm)
:print(TrgIm)
:print(SrcLabmapIm)
:print(TxSrcLabmapIm)
: