platipy.imaging.projects.bronchus package#

Submodules#

platipy.imaging.projects.bronchus.bronchus module#

Created on Wed Feb 21 16:39:27 2018

Bronchus segmentation. The superior extent of bronchus is around 4cm SUP from Carina (From first slice where two airways become visible). In this code I’m using 2cm as it’s easier to detect where the airways are getting wider

Areas to improve: parameters could be improved (eg. the median filter, carina detection, etc). The GenLung_mask is based on old ITK code from a masters student. I think we can replace this function by checking the top (sup) slice for an airhole and then connected thresholding.

Code fails on two Liverpool cases: 13 (lungs appear in the sup slice) and 36 (the mask failed to generate - need to look at this)

@author: Jason Dowling (CSIRO)

platipy.imaging.projects.bronchus.bronchus.fast_mask(img, start, end)#

Fast masking for area of a 3D volume .

SimpleITK lacks iterators so voxels need to be set with SetPixel which is horribly slow. This code uses numpy arrays to reduce time for one volume from around one minute to about 0.5s

Parameters:

image – Input 3D binary image, start slice for masking (value=0), end slice for masking

Returns:

Masked image. This may be in float, so it might need casting back to original pixel type.

platipy.imaging.projects.bronchus.bronchus.generate_airway_mask(dest, img, lung_mask, config_dict=None)#

Generate final bronchus segmentation .

Parameters:

image – path for CT image and mask destination

Returns:

None

platipy.imaging.projects.bronchus.bronchus.generate_lung_mask(img)#

Generate initial airway mask (includes lungs).

Parameters:

img – The SimpleITK CT image to segment the lungs in

Returns:

The mask containing the lung segmentation

Return type:

lung_mask

platipy.imaging.projects.bronchus.bronchus.get_distance(a_mask, b_mask)#

Get the nearest distance between two masks.

Parameters:
  • a_mask – The first mask

  • b_mask – The second mask

  • dest – Working directory to output intermediate files

Returns:

None

platipy.imaging.projects.bronchus.run module#

platipy.imaging.projects.bronchus.run.run_bronchus_segmentation(input_image, settings={'algorithmSettings': {'distance_from_supu_slice_values': [3, 10, 20], 'expected_physical_size_range': [22000, 150000], 'extend_from_carina_mm': 40, 'fast_mode': True, 'lung_mask_hu_values': [-750, -775, -800, -825, -850, -900, -700, -950, -650], 'minimum_tree_half_physical_size': 1000}, 'outputBronchusName': 'Auto_Bronchus', 'outputLungName': 'Auto_Lung'})#

Runs the Proximal Bronchial Tree segmentation

Parameters:
  • input_image (sitk.Image) – SimpleITK image on which to perform the segmentation

  • settings (dict, optional) – Dictionary containing settings for algorithm. Defaults to BRONCHUS_SETTINGS_DEFAULTS.

Returns:

Dictionary containing output of segmentation

Return type:

dict

platipy.imaging.projects.bronchus.service module#

Module contents#