Repository navigation
8000
No one assignedNo labelsNo typeNo projectsNo milestoneNone yetNo branches or pull requests
Open
Description
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?)
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. ]])
)
Metadata
Metadata
Assignees
Labels
No labels
Activity