Automatic input function#

calculate_PET_mask(meanpet)#

calculate liberal PET mask covering possible frame by frame motion

calculate_PET_mean(pet)#
connect_points(img, point_list)#

Creates a line through specified points in a matrix

Connects two points in a matrix (image). Returns a mask image where background is 0 and the original points and lines drawn are 1. Works on n >= 2 dimensions. The order of connection is p1->p2, p2->p3, …, pn-1 -> pn. If you want lines that are not connected in this order, call this function multiple times with the pairs you want to connect.

Parameters:
  • img (array) – Image array.

  • point_list (PxN array) –

    List of points you want to connect. Format is [p1;p2;…;pn], eg.

    x y z

    p1 [1 2 3 p2 3 5 1 p3 9 4 2]

Returns:

new_img – Mask image where the original points and the line are 1 and background is zero. unchanged.

Return type:

array

crop_to_mask(petfile, mask_idx, result_file, options)#

Crops image to bounding box around the mask (+optional padding)

Parameters:
  • petfile (char array) – Full filepath to pet image, eg. /my/nifti/file.nii.

  • mask_idx (double array) – Either linear indice list or X*Y*Z array with mask area set to > 0. Note that before taking the mask, the mask image needs to be resliced to pet image dimensions.

  • result_file (char array) – Full filepath to result file that is created, eg. /my/result/file.nii.

  • padding (6x1 int array, default: [0,0,0,0,0,0]) – Padding for each dimension. After the bounding box is calculated, padding values are used to enlarge it in each dimension. Format: [x_start, x_end, y_start, y_end, z_start, z_end]

  • verbose (int, default: 1) –

    • 0, do not print information about program execution.

    • 1, print information about program execution.

get_auto_input_func(PETfile, targetROI_idx, landmarkROI_idx, grow_direction, output_folder, filename, verbose)#

Creates automatic mask for input function in abdominal aorta.

First a sum of first 10 frames is created. Then the aorta is extracted from this image using the CT segmentation. All regional maximums are searched from this image. Only maximums that are within the boundaries are selected. The upper boundary is determined from the lower 1/3 of myocardium and goes down 10 cm for the lower boundary.

Then the first local maximums over the boundaries are selected from each side and added to the list. Duplicate maximums in the same plane are deleted. These points are then connected from top to bottom (simple line between points). Positive voxels outside of boundaries are set to 0. Then this single voxel wide line is dilated.

Parameters:
  • PETfile (char array) – Full path to the PET file.

  • targetROI_idx (Vx1 array) – Linear indices of where the (aorta) mask is positive.

  • array (landmarkROI_idx Wx1) – Linear indices of where the (myocardium) landamark mask is positive.

  • grow_direction (['x', 'y', 'z']) – Which axis is used for the connecting. Use ‘z’ for aorta.

  • output_folder (char array) – Folder where the resulting image is saved. Created if not present already.

  • filename (char array) – Name for the resulting mask file.

  • verbose (int) –

    Print and save additional information.

    • 0, no print or saving.

    • 1, print information and no saving.

    • >= 2, print and save intermediate images.

Returns:

  • input_curve (Nx1 double array) – Input values. Mean value inside the automatically created mask in each frame.

  • input_mask_img (array) – The mask image matrix.

Notes

Saves output file to output_folder/filename.nii

match_input_unit(input, pet)#

match input units with PET data

normpdf(x, mean, sigma)#

NORMPDF.M calculates and plots a normal probability density function.

PSVsmooth_3d(im, sd, l)#
sub2ind_(siz, sub_list)#

Modified version from Matlab’s native function.

See Matlabs documentation. This function is modified to accept vectors.

SUB2IND Linear index from multiple subscripts. SUB2IND is used to determine the equivalent single index corresponding to a given set of subscript values.

IND = SUB2IND(SIZ,I,J) returns the linear index equivalent to the row and column subscripts in the arrays I and J for a matrix of size SIZ.

IND = SUB2IND(SIZ,I1,I2,…,IN) returns the linear index equivalent to the N subscripts in the arrays I1,I2,…,IN for an array of size SIZ.

I1,I2,…,IN must have the same size, and IND will have the same size as I1,I2,…,IN. For an array A, if IND = SUB2IND(SIZE(A),I1,…,IN)), then A(IND(k))=A(I1(k),…,IN(k)) for all k.

Class support for inputs I,J:

float: double, single integer: uint8, int8, uint16, int16, uint32, int32, uint64, int64

See also IND2SUB.