2.1.1.6. rpt_dosi.images

2.1.1.6.1. Attributes

image_builders

2.1.1.6.2. Classes

MetaImageBase

Class to manage metadata, providing methods to convert to/from dict and JSON.

MetaImageCT

Class to manage metadata, providing methods to convert to/from dict and JSON.

MetaImageSPECT

Class to manage metadata, providing methods to convert to/from dict and JSON.

MetaImagePET

Class to manage metadata, providing methods to convert to/from dict and JSON.

MetaImageROI

Class to manage metadata, providing methods to convert to/from dict and JSON.

MetaImageDose

Class to manage metadata, providing methods to convert to/from dict and JSON.

2.1.1.6.3. Functions

read_metaimage(file_path[, reading_mode])

Read an existing metaimage.

metadata_exists(file_path)

new_metaimage(image_type, file_path[, overwrite, ...])

Create (and read) a new metaimage.

get_metaimage_class_from_type(image_type)

read_metaimage_type_from_metadata(file_path)

delete_image_metadata(file_path)

read_ct(filepath)

Read or create a CT image

read_spect(filepath[, unit])

Read or create a SPECT image and consider the given unit

read_pet(filepath[, unit])

Read or create a PET image and consider the given unit

read_roi(filepath[, name, effective_time_h])

Read or create a ROI image and consider the given unit

read_dose(filepath[, unit])

Read or create a Dose image and consider the given unit

read_list_of_rois(filename[, folder])

images_have_same_domain(image1, image2[, tolerance])

validate_spacing(ctx, param, value)

images_have_same_spacing(image1, image2[, tolerance])

image_has_this_spacing(image1, spacing[, tolerance])

resample_itk_image_like(img, like_img, ...)

resample_itk_image_spacing(img, new_spacing, ...)

image_set_background(ct, roi[, bg_value, roi_bg_value])

get_pixel_value_range(pixel_type)

crop_to_bounding_box(img[, lover_threshold])

convert_ct_to_densities(ct)

apply_itk_gauss_smoothing(img, sigma)

resample_ct_like(ct, like[, gaussian_sigma])

resample_dose_like(dose, like[, gaussian_sigma])

resample_ct_spacing(ct, spacing[, gaussian_sigma])

resample_spect_like(spect, like[, gaussian_sigma])

resample_spect_spacing(spect, spacing[, gaussian_sigma])

resample_roi_like(roi, like)

resample_roi_spacing(roi, spacing)

test_compare_images(image1, image2[, tol])

dilate_mask(img, dilatation_mm)

mip(img[, dim3])

image_roi_stats(roi, spect[, ct, resample_like])

mhd_find_raw_file(mhd_file_path)

mhd_replace_raw(mhd_file_path, new_raw_filename)

is_mhd_file(file_path)

mhd_copy_or_move(mhd_path, new_mhd_path[, mode])

copy_or_move_image(source_path, dest_path, mode)

get_time_from_injection_h(injection_datetime, ...)

set_time_from_injection_h(injection_datetime, ...)

compute_image_extent(sitk_image)

compute_combined_fov_extent(sitk_image1, sitk_image2)

create_empty_sitk_image_from_extent(...[, pixel_type])

roi_boolean_operation(sitk_img1, sitk_img2, bool_operator)

2.1.1.6.4. Module Contents

rpt_dosi.images.read_metaimage(file_path, reading_mode='image')[source]

Read an existing metaimage. Need both the image and the associated metadata json sidecar file.

reading_mode: - image - header_only - metadata_only

rpt_dosi.images.metadata_exists(file_path)[source]
rpt_dosi.images.new_metaimage(image_type, file_path, overwrite=False, reading_mode='metadata_only', **kwargs)[source]

Create (and read) a new metaimage. The filepath of the image must exist. The associated metadata json sidecar file is created (or overwritten if already exist) The required parameters must be given for some image_type : - SPECT require ‘unit’ - ROI require ‘name’

rpt_dosi.images.get_metaimage_class_from_type(image_type)[source]
rpt_dosi.images.read_metaimage_type_from_metadata(file_path)[source]
rpt_dosi.images.delete_image_metadata(file_path)[source]
rpt_dosi.images.read_ct(filepath)[source]

Read or create a CT image

rpt_dosi.images.read_spect(filepath, unit=None)[source]

Read or create a SPECT image and consider the given unit

rpt_dosi.images.read_pet(filepath, unit=None)[source]

Read or create a PET image and consider the given unit

rpt_dosi.images.read_roi(filepath, name=None, effective_time_h=None)[source]

Read or create a ROI image and consider the given unit

rpt_dosi.images.read_dose(filepath, unit=None)[source]

Read or create a Dose image and consider the given unit

rpt_dosi.images.read_list_of_rois(filename, folder=None)[source]
class rpt_dosi.images.MetaImageBase(image_path, reading_mode, create=False, **kwargs)[source]

Bases: rpt_dosi.metadata.ClassWithMetaData

Class to manage metadata, providing methods to convert to/from dict and JSON. The class fields that are considered as metadata are store in _metadata_fields.

authorized_units = [][source]
unit_default_values[source]
image_type = None[source]
unit_converter[source]
_metadata_fields[source]
image = None[source]
description = ''[source]
_acquisition_datetime = None[source]
body_weight_kg = None[source]
_image_filename = None[source]
_image_file_path = None[source]
_image_header = None[source]
_unit = None[source]
_unit_default_value = 0[source]
property image_file_path[source]
_init_required_metadata(**kwargs)[source]
ensure_image_is_loaded()[source]
image_is_loaded()[source]
property unit[source]
property filename[source]
require_unit(unit)[source]
convert_to_unit(new_unit)[source]
property voxel_volume_cc[source]
property voxel_volume_ml[source]
property unit_default_value[source]
property acquisition_datetime[source]
read(file_path=None)[source]
write(file_path=None, writing_mode='image')[source]
read_metadata()[source]
read_image_header()[source]
write_metadata()[source]
property metadata_file_path[source]
info()[source]
check_file_metadata()[source]
class rpt_dosi.images.MetaImageCT(image_path, reading_mode, create=False, **kwargs)[source]

Bases: MetaImageBase

Class to manage metadata, providing methods to convert to/from dict and JSON. The class fields that are considered as metadata are store in _metadata_fields.

authorized_units = ['HU', 'g/cm3'][source]
unit_default_values[source]
image_type = 'CT'[source]
unit = 'HU'[source]
compute_densities()[source]
class rpt_dosi.images.MetaImageSPECT(image_path, reading_mode, create=False, **kwargs)[source]

Bases: MetaImageBase

Class to manage metadata, providing methods to convert to/from dict and JSON. The class fields that are considered as metadata are store in _metadata_fields.

authorized_units = ['Bq', 'Bq/mL', 'SUV'][source]
unit_default_values[source]
image_type = 'SPECT'[source]
unit_converter[source]
_metadata_fields[source]
_injection_datetime = None[source]
injection_activity_mbq = None[source]
_init_required_metadata(**kwargs)[source]
property injection_datetime[source]
info()[source]
convert_to_bq()[source]
convert_to_bqml()[source]
convert_to_suv()[source]
compute_total_activity()[source]
property time_from_injection_h[source]
write_metadata()[source]
class rpt_dosi.images.MetaImagePET(image_path, reading_mode, create=False, **kwargs)[source]

Bases: MetaImageSPECT

Class to manage metadata, providing methods to convert to/from dict and JSON. The class fields that are considered as metadata are store in _metadata_fields.

authorized_units = ['Bq/mL', 'SUV'][source]
unit_default_values[source]
image_type = 'PET'[source]
_injection_datetime = None[source]
injection_activity_mbq = None[source]
_init_required_metadata(**kwargs)[source]
class rpt_dosi.images.MetaImageROI(image_path, reading_mode, create=False, **kwargs)[source]

Bases: MetaImageBase

Class to manage metadata, providing methods to convert to/from dict and JSON. The class fields that are considered as metadata are store in _metadata_fields.

authorized_units = ['label'][source]
unit_default_values[source]
image_type = 'ROI'[source]
_metadata_fields[source]
name = None[source]
_unit = 'label'[source]
effective_time_h = None[source]
mass_g = None[source]
volume_cc = None[source]
_init_required_metadata(**kwargs)[source]
info()[source]
update_mass_and_volume(density_ct)[source]
write_metadata()[source]
class rpt_dosi.images.MetaImageDose(image_path, reading_mode, create=False, **kwargs)[source]

Bases: MetaImageSPECT

Class to manage metadata, providing methods to convert to/from dict and JSON. The class fields that are considered as metadata are store in _metadata_fields.

authorized_units = ['Gy', 'Gy/s'][source]
unit_default_values[source]
image_type = 'Dose'[source]
_init_required_metadata(**kwargs)[source]
rpt_dosi.images.image_builders[source]
rpt_dosi.images.images_have_same_domain(image1, image2, tolerance=1e-05)[source]
rpt_dosi.images.validate_spacing(ctx, param, value)[source]
rpt_dosi.images.images_have_same_spacing(image1, image2, tolerance=1e-05)[source]
rpt_dosi.images.image_has_this_spacing(image1, spacing, tolerance=1e-05)[source]
rpt_dosi.images.resample_itk_image_like(img, like_img, default_pixel_value, linear)[source]
rpt_dosi.images.resample_itk_image_spacing(img, new_spacing, default_pixel_value, linear)[source]
rpt_dosi.images.image_set_background(ct, roi, bg_value=-1000, roi_bg_value=0)[source]
rpt_dosi.images.get_pixel_value_range(pixel_type)[source]
rpt_dosi.images.crop_to_bounding_box(img, lover_threshold=-1000)[source]
rpt_dosi.images.convert_ct_to_densities(ct)[source]
rpt_dosi.images.apply_itk_gauss_smoothing(img, sigma)[source]
rpt_dosi.images.resample_ct_like(ct: MetaImageCT, like: MetaImageBase, gaussian_sigma=None)[source]
rpt_dosi.images.resample_dose_like(dose: MetaImageDose, like: MetaImageBase, gaussian_sigma=None)[source]
rpt_dosi.images.resample_ct_spacing(ct: MetaImageCT, spacing, gaussian_sigma=None)[source]
rpt_dosi.images.resample_spect_like(spect: MetaImageSPECT, like: MetaImageBase, gaussian_sigma=None)[source]
rpt_dosi.images.resample_spect_spacing(spect: MetaImageSPECT, spacing, gaussian_sigma=None)[source]
rpt_dosi.images.resample_roi_like(roi: MetaImageROI, like: MetaImageBase)[source]
rpt_dosi.images.resample_roi_spacing(roi: MetaImageROI, spacing)[source]
rpt_dosi.images.test_compare_images(image1, image2, tol=1e-06)[source]
rpt_dosi.images.dilate_mask(img, dilatation_mm)[source]
rpt_dosi.images.mip(img, dim3=False)[source]
rpt_dosi.images.image_roi_stats(roi, spect, ct=None, resample_like='spect')[source]
rpt_dosi.images.mhd_find_raw_file(mhd_file_path)[source]
rpt_dosi.images.mhd_replace_raw(mhd_file_path, new_raw_filename)[source]
rpt_dosi.images.is_mhd_file(file_path)[source]
rpt_dosi.images.mhd_copy_or_move(mhd_path, new_mhd_path, mode='copy')[source]
rpt_dosi.images.copy_or_move_image(source_path, dest_path, mode)[source]
rpt_dosi.images.get_time_from_injection_h(injection_datetime, acquisition_datetime)[source]
rpt_dosi.images.set_time_from_injection_h(injection_datetime, acquisition_datetime, time_from_injection_h)[source]
rpt_dosi.images.compute_image_extent(sitk_image)[source]
rpt_dosi.images.compute_combined_fov_extent(sitk_image1, sitk_image2)[source]
rpt_dosi.images.create_empty_sitk_image_from_extent(combined_extent_min, combined_extent_max, spacing, pixel_type=sitk.sitkFloat32)[source]
rpt_dosi.images.roi_boolean_operation(sitk_img1, sitk_img2, bool_operator, spacing=None)[source]