8000 CT register to MRI issues · Issue #497 · nipy/nipy · GitHub
[go: up one dir, main page]

Skip to content
8000

CT register to MRI issues #497

Open
Open

Description

@dipterix

Hi,

I was trying to coregister CT to MRI using the following command:

# smooth=0., reg_type='rigid', target_file = "orig.mgz", source_file = "CT_raw.nii"
#  interp='pv', optimizer='powell', xtol=0.0001, ftol=0.0001, noresample=True

ctimg  = nipy.load_image(filename=source_file)
mrimg = nipy.load_image(filename=target_file)
ct_cmap = ctimg.coordmap  
mr_cmap = mrimg.coordmap

ct_to_mri_reg = nipy.algorithms.registration.histogram_registration.HistogramRegistration(
  from_img=ctimg, to_img=mrimg, similarity='nmi', smooth=smooth, interp=interp)
aff = ct_to_mri_reg.optimize(reg_type, optimizer=optimizer, xtol=xtol, ftol=ftol).as_affine()   

ct_to_mri = AffineTransform(ct_cmap.function_range, mr_cmap.function_range, aff)  
reg_CT = nipy.algorithms.resample.resample(ctimg, mr_cmap, ct_to_mri.inverse(), mrimg.shape)    

outfile = os.path.join(source_directory, 'CT_registered.nii')
nipy.save_image(reg_CT, outfile, dtype_from="data")

The affine matrix was almost identity matrix, and coregistered CT had nothing in it . Did I miss anything? (Like do I need to manually remove the metals in the CT?)

image

The CT and MR IJK to RAS transforms are as follows: (click to expand)
ct_cmap
AffineTransform(
   function_domain=CoordinateSystem(coord_names=('i', 'j', 'k'), name='voxels', coord_dtype=float64),
   function_range=CoordinateSystem(coord_names=('scanner-x=L->R', 'scanner-y=P->A', 'scanner-z=I->S'), name='scanner', coord_dtype=float64),

4AA2
   affine=array([[-4.60937500e-01,  0.00000000e+00, -0.00000000e+00,
                   1.17769531e+02],
                 [-0.00000000e+00,  4.60937500e-01, -0.00000000e+00,
                   4.12304688e+01],
                 [ 0.00000000e+00,  0.00000000e+00,  1.00000000e+00,
                   1.10669995e+03],
                 [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00,
                   1.00000000e+00]])
)
>>> mr_cmap
AffineTransform(
   function_domain=CoordinateSystem(coord_names=('i', 'j', 'k'), name='voxels', coord_dtype=float64),
   function_range=CoordinateSystem(coord_names=('scanner-x=L->R', 'scanner-y=P->A', 'scanner-z=I->S'), name='scanner', coord_dtype=float64),
   affine=array([[ -1.        ,   0.        ,   0.        , 126.39163971],
                 [  0.        ,   0.        ,   1.        , -94.04666138],
                 [  0.        ,  -1.        ,   0.        , 143.81729126],
                 [  0.        ,   0.        ,   0.        ,   1.        ]])
)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0