niftynet.io.misc_io module

niftynet.io.misc_io.correct_image_if_necessary(img)
niftynet.io.misc_io.create_affine_pixdim(affine, pixdim)

Given an existing affine transformation and the pixel dimension to apply, create a new affine matrix that satisfies the new pixel dimension :param affine: original affine matrix :param pixdim: pixel dimensions to apply :return:

niftynet.io.misc_io.do_reorientation(data_array, init_axcodes, final_axcodes)

Performs the reorientation (changing order of axes) :param data_array: Array to reorient :param ornt_init: Initial orientation :param ornt_fin: Target orientation :return data_reoriented: New data array in its reoriented form

niftynet.io.misc_io.do_resampling(data_array, pixdim_init, pixdim_fin, interp_order)

Performs the resampling :param data_array: Data array to resample :param pixdim_init: Initial pixel dimension :param pixdim_fin: Targeted pixel dimension :param interp_order: Interpolation order applied :return data_resampled: Array containing the resampled data

niftynet.io.misc_io.expand_to_5d(img_data)

Expands an array up to 5d if it is not the case yet :param img_data: :return:

niftynet.io.misc_io.get_latest_subfolder(parent_folder, create_new=False)
niftynet.io.misc_io.image3(name, tensor, max_outputs=3, collections=['summaries'], animation_axes=[1], image_axes=[2, 3], other_indices={})

Summary for higher dimensional images Parameters: name: string name for the summary tensor: tensor to summarize. Should be in the range 0..255.

By default, assumes tensor is NDHWC, and animates (through D) HxW slices of the 1st channel.

collections: list of strings collections to add the summary to animation_axes=[1],image_axes=[2,3]

niftynet.io.misc_io.image3_axial(name, tensor, max_outputs=3, collections=['summaries'])
niftynet.io.misc_io.image3_coronal(name, tensor, max_outputs=3, collections=['summaries'])
niftynet.io.misc_io.image3_sagittal(name, tensor, max_outputs=3, collections=['summaries'])
niftynet.io.misc_io.infer_ndims_from_file(file_path)
niftynet.io.misc_io.load_image(filename)
niftynet.io.misc_io.rectify_header_sform_qform(img_nii)

Look at the sform and qform of the nifti object and correct it if any incompatibilities with pixel dimensions :param img_nii: :return:

niftynet.io.misc_io.resolve_checkpoint(checkpoint_name)
niftynet.io.misc_io.save_data_array(filefolder, filename, array_to_save, image_object=None, interp_order=3, reshape=True)

write image data array to hard drive using image_object properties such as affine, pixdim and axcodes.

niftynet.io.misc_io.save_volume_5d(img_data, filename, save_path, affine=array([[ 1., 0., 0., 0.], [ 0., 1., 0., 0.], [ 0., 0., 1., 0.], [ 0., 0., 0., 1.]]))

Save the img_data to nifti image :param img_data: 5d img to save :param filename: filename under which to save the img_data :param save_path: :param affine: an affine matrix. :return:

niftynet.io.misc_io.set_logger(file_name=None)
niftynet.io.misc_io.split_filename(file_name)
niftynet.io.misc_io.squeeze_spatial_temporal_dim(tf_tensor)

Given a tensorflow tensor, ndims==6 means: [batch, x, y, z, time, modality] this function removes x, y, z, and time dims if the length along the dims is one :return: squeezed tensor

niftynet.io.misc_io.touch_folder(model_dir)

This funciton returns the absolute path of model_dir if exists otherwise try to create the folder and returns the absolute path