Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CT register to MRI issues #497

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

Open
dipterix opened this issue Dec 26, 2022 · 0 comments
Open

CT register to MRI issues #497

dipterix opened this issue Dec 26, 2022 · 0 comments

Comments

@dipterix
Copy link

dipterix commented Dec 26, 2022

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),
   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.        ]])
)
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

1 participant