API details.

The transformation function

binarize_mask[source]

binarize_mask(input_image)

Main function for creating nifti image.

Takes a nifti image, binarizes it and transforms to uint8 and outputs a new image.

def binarize_mask(input_image):
    '''
    Main function for creating nifti image. 
    
    Takes a nifti image, binarizes it and transforms to uint8 and outputs a new image.
    '''
    transform_formula = '((i > 0) * 1).astype(np.uint8)'
    out_image = image.math_img(transform_formula, i=input_image)
    return out_image

Util to load_data

data_loader[source]

data_loader(inpath)

Loads a nifti image at inpath using nibabel.

data_saver[source]

data_saver(nifti, outpath)

Tries to save nifti using nibabel, if fails returns False.

Path-handling

Just some general utils to handle paths. And performing some checks on directories.

outpath_from_inpath[source]

outpath_from_inpath(inpath)

Returns the directories name.

check_outpath[source]

check_outpath(outpath)

create_outpath[source]

create_outpath(imagename, outpath, prefix)

Putting path funtions together

savingpath[source]

savingpath(inpath, outpath=None, prefix='bin_')

Main Function

Mask transform handles the file I/O and applies binarize_mask on the image.

mask_transform[source]

mask_transform(inpath, outpath=None, prefix='bin_')

CLI

nifti_binarizer is the CLI for mask_transform and will be accessible after installing the package from pip.

nifti_binarizer[source]

nifti_binarizer()