unravel.register.reg module#

Use reg from UNRAVEL to register an average template brain/atlas to a resampled autofl brain.

Prereqs:

reg_prep, [seg_copy_tifs], & [seg_brain_mask]

Inputs:
  • template to register (e.g., gubra_template_CCFv3_30um.nii.gz, an iDISCO/LSFM template in CCFv3 space)

  • reg_inputs/autofl_50um_masked.nii.gz (from reg_prep)

  • atlas/atlas_CCFv3_2020_30um.nii.gz (default; from Allen Brain Institute)

Outputs:
  • reg_outputs/autofl_50um_masked_fixed_reg_input.nii.gz (padded fixed image used for registration with ANTsPy)

  • reg_outputs/<atlas>_in_tissue_space.nii.gz (warped atlas to tissue space for checking reg)

  • transformation matrices and deformation fields in reg_outputs

Note

  • Images in reg_inputs are not padded.

  • Images in reg_outputs have 15% padding.

  • ort_code is a 3 letter orientation code of the fixed image if not set in fixed_img (e.g., RAS)

  • Letter options: A/P=Anterior/Posterior, L/R=Left/Right, S/I=Superior/Inferior

  • The side of the brain at the positive direction of the x, y, and z axes determines the 3 letters (axis order xyz)

Next commands:

reg_check for assessing registration, vstats_prep for preparing voxel-wise stats inputs, or rstats for regional stats.

Usage for tissue registration:#

reg -m <path/template.nii.gz> -bc -sm 0.4 -ort <3 letter orientation code> [-m2 atlas/atlas_CCFv3_2020_30um.nii.gz] [-f reg_inputs/autofl_50um_masked.nii.gz] [-mas reg_inputs/autofl_50um_brain_mask.nii.gz] [-ro reg_outputs] [-bc] [-sm 0.4] [-d list of paths] [-p sample??] [-v]

Usage for atlas to atlas registration:#

reg -m <path/atlas1.nii.gz> -f <path/atlas2.nii.gz> -m2 <path/atlas2.nii.gz> [-d list of paths] [-p sample??] [-v]

Usage for template to template registration:#

reg -m <path/template1.nii.gz> -f <path/template2.nii.gz> -m2 <path/template2.nii.gz> -inp linear [-d list of paths] [-p sample??] [-v]

unravel.register.reg.parse_args()[source]#
unravel.register.reg.bias_correction(image_path, mask_path=None, shrink_factor=2, verbose=False)[source]#

Perform N4 bias field correction on a .nii.gz and return an ndarray

Parameters:
  • image_path (str) – Path to input image.nii.gz

  • mask_path (str) – Path to mask image.nii.gz

  • shrink_factor (int) – Shrink factor for bias field correction

  • verbose (bool) – Print output

  • output_dir (str) – Path to save corrected image

unravel.register.reg.main()[source]#