unravel.register.adjust_template module#
Use reg_adjust_template (rat) from UNRAVEL to adjust intensities in a template for a single set of atlas label IDs.
Note
The boundary between the adjusted region and the rest of the image can be sharp or blurred by applying a Gaussian blur to a two-sided boundary band around the region.
- The boundary band is computed as:
inside band = region - erosion(region, band_width) outside band = dilation(region, band_width) - region band = inside OR outside
We blur the full (modified) image, then replace only band voxels with blurred values.
Example of use (separate steps):#
# 1) Fiber tracts: scale by 0.85 reg_adjust_template -i template.nii.gz -a atlas.nii.gz -ids <FIBER_IDS…> –scale 0.85 -bb -o template_fibers.nii.gz
# 2) HPF: scale by 0.8 (using previous output) reg_adjust_template -i template_fibers.nii.gz -a atlas.nii.gz -ids <HPF_IDS…> –scale 0.8 -bb -o template_fibers_hpf.nii.gz
# 3) DG/CAsp: scale by 2.0 (using previous output) reg_adjust_template -i template_fibers_hpf.nii.gz -a atlas.nii.gz -ids <DG_CAsp_IDS…> –scale 2.0 -bb -o template_fibers_hpf_dg.nii.gz
Usage:#
reg_adjust_template -i path/image.nii.gz -a path/atlas_labels.nii.gz -ids <ID1> <ID2> … -o path/output.nii.gz [–scale <factor> | –set <value>] [-bb -s <float> -bw <int>] [-dt <dtype>] [-v]
- unravel.register.adjust_template.mask_from_ids(atlas, ids)[source]#
Binary mask where atlas label is in ids.
- unravel.register.adjust_template.boundary_band_mask(region_mask, band_width=1)[source]#
- Two-sided boundary band:
inside band = region - erode(region, n) outside band = dilate(region, n) - region band = inside OR outside
- Parameters:
region_mask (ndarray) –
band_width (int) –
- Return type:
ndarray