Extraction API

Contrast phase

imperandi.extract.phase.add_phase_arguments(parser, include_dry_run=True)[source]

Add phase-extraction paths, force, and resume options to a parser.

Parameters:
  • parser (ArgumentParser)

  • include_dry_run (bool)

Return type:

None

imperandi.extract.phase.build_parser(add_help=True)[source]

Build the standalone CT contrast-phase extraction parser.

Parameters:

add_help (bool)

Return type:

ArgumentParser

imperandi.extract.phase.main(args)[source]

Extract phase metadata for a cohort with checkpoint-aware resuming.

Parameters:

args (Namespace)

Return type:

None

imperandi.extract.phase.normalize_phase_args(args)[source]

Resolve phase input, output, and error paths in-place.

Raises:
  • FileNotFoundError – If the input table does not exist.

  • ValueError – If the input table is not a CSV file.

Parameters:

args (Namespace)

Return type:

Namespace

imperandi.extract.phase.parse_arguments()[source]

Parse and normalize arguments for standalone phase extraction.

Return type:

Namespace

imperandi.extract.phase.process_single_volume(idx, row, *, phase_extractor, verbose=False)[source]

Extract phase metadata for one cohort row without raising row errors.

Returns:

(row_index, metadata, error). Successful metadata keys are prefixed with totalseg_; failures return an error string instead.

Parameters:
  • idx (int)

  • row (Mapping[str, Any])

  • phase_extractor (Callable[[Any], Dict[str, Any]])

  • verbose (bool)

Return type:

Tuple[int, Dict[str, Any] | None, str | None]

Radiomics

imperandi.extract.radiomics.add_radiomics_arguments(parser, include_dry_run=True)[source]

Add radiomics paths, settings, filters, and resume options to a parser.

Parameters:
  • parser (ArgumentParser)

  • include_dry_run (bool)

Return type:

None

imperandi.extract.radiomics.build_parser(add_help=True)[source]

Build the standalone PyRadiomics extraction parser.

Parameters:

add_help (bool)

Return type:

ArgumentParser

imperandi.extract.radiomics.extract_radiomics_organ_minus_tumor(image_path, organ_mask_path, tumor_mask_path, *, extractors, sitk_module, prefix='liver', row_idx=None)[source]

Extract organ features after excluding an optional paired tumor mask.

Shape features use the full organ mask, while non-shape features use the organ-minus-tumor region. If no usable tumor mask exists, all features are extracted from the organ.

Parameters:
  • image_path (str)

  • organ_mask_path (str | None)

  • tumor_mask_path (str | None)

  • prefix (str)

  • row_idx (int | None)

Return type:

Tuple[Dict[str, Any], str | None]

imperandi.extract.radiomics.extract_radiomics_safe(image_path, mask_path, prefix, *, extractors, sitk_module, row_idx=None)[source]

Extract all enabled features for one image/mask pair.

Returns:

A (features, error) tuple. Expected row-level failures are captured as an error string rather than raised.

Parameters:
  • image_path (str)

  • mask_path (str | None)

  • prefix (str)

  • row_idx (int | None)

Return type:

Tuple[Dict[str, Any], str | None]

imperandi.extract.radiomics.main(args)[source]

Extract radiomics for cohort mask columns with filters and checkpoints.

Parameters:

args (Namespace)

Return type:

None

imperandi.extract.radiomics.mask_has_voxels(mask, sitk_module)[source]

Return whether a SimpleITK-compatible mask contains non-zero voxels.

Return type:

bool

imperandi.extract.radiomics.normalize_radiomics_args(args)[source]

Resolve radiomics paths, filters, and settings arguments in-place.

Parameters:

args (Namespace)

Return type:

Namespace

imperandi.extract.radiomics.parse_arguments()[source]

Parse and normalize arguments for standalone radiomics extraction.

Return type:

Namespace