histsetup module

histsetup.downsample_slices(subject_dir, output_dir, ext='', slice_downfactor=1, image_downfactor=1, sep='_', fnumidx=-1)[source]

Downsample Slices

Copy a subset of optionally downsampled 2D images to the output directory.

Parameters
  • subject_dir (str) – Path to image series

  • output_dir (str) – Output path

  • ext (str) – subject image file extension (e.g. ‘png’)

  • slice_downfactor (int) – Specifies n, where every nth image will be copied to the output folder.

  • image_downfactor (int) – Image downsampling factor.

Example

>>> subject_dir = '/path/to/histology/data
>>> output_dir = 'example_outputs'
>>> downsample_slices(subject_dir, output_dir, ext='png', slice_downfactor=20, image_downfactor=32)
Raises

FileNotFoundError – If the subject directory does not exist.

histsetup.generate_sidecars(subject_dir, ext='', max_slice=None, dtype='uint8', dv=[14.72, 14.72, 10.0], slice_downfactor=1, sep='_', fnumidx=-1, space='right-inferior-posterior')[source]

Generate Sidecar Files

Saves out JSON format sidecare files for each image in the dataset.

Parameters
  • subject_dir (str) – Path to image series

  • ext (str) – image file extension (e.g. ‘png’)

  • max_slice (int) – Number of slices in the original dataset (used to calcuate spatial information for the slices).

  • dtype (str) – Image data type

  • dv (list of float) – voxel spacing in microns (ordered: row, col, slice)

  • slice_downfactor (int) – Factor used to reduce the number of images from the original dataset.

Example

>>> subject_dir = 'example_outputs'
>>> generate_sidecars(subject_dir, 'png', max_slice=1389, dv=[14.72,14.72,10.0])
MD787-N1-2019.03.28-21.52.46_MD787_1_0001.json
MD787-N7-2019.03.28-22.05.43_MD787_3_0021.json
MD787-N14-2019.03.28-22.20.46_MD787_2_0041.json
...
Raises

FileNotFoundError – If the subject directory does not exist.

histsetup.main()[source]
histsetup.make_samples_tsv(subject_dir, ext='', slice_downfactor=1, max_slice=None, sep='_', fnumidx=-1)[source]

Make ‘samples.tsv’ file

Saves a tsv file listing the images in the folder.

Parameters
  • subject_dir (path) – Path to the dataset.

  • ext (str) – image file extension (e.g. ‘png’)

  • max_slice (int) – Number of slices in the original dataset (not currently used)

Example

>>> subject_dir = 'example_outputs'
>>> make_samples_tsv(subject_dir, 'png')
Raises

FileNotFoundError – If the subject directory does not exist.