mantidimaging.gui.windows.spectrum_viewer.model module

class mantidimaging.gui.windows.spectrum_viewer.model.SpecType(value)[source]

Bases: Enum

An enumeration.

OPEN = 2
SAMPLE = 1
SAMPLE_NORMED = 3
class mantidimaging.gui.windows.spectrum_viewer.model.SpectrumViewerWindowModel(presenter: SpectrumViewerWindowPresenter)[source]

Bases: object

The model for the spectrum viewer window. This model is responsible for storing the state of the window and providing the presenter with the data it needs to update the view. The model is also responsible for saving ROI data to a csv file.

get_averaged_image() ndarray | None[source]

Get the averaged image from the stack in the model returning as a numpy array or None if it does not

get_image_shape() tuple[int, int][source]
get_list_of_roi_names() list[str][source]

Get a list of rois available in the model

get_roi(roi_name: str) SensibleROI[source]

Get the ROI with the given name from the model

@param roi_name: The name of the ROI to get @return: The ROI with the given name

get_roi_coords_filename(path: Path) Path[source]

Get the path to save the ROI coordinates to. @param path: The path to save the CSV file to. @return: The path to save the ROI coordinates to.

get_spectrum(roi_name: str, mode: SpecType) ndarray[source]
static get_stack_spectrum(stack: ImageStack, roi: SensibleROI)[source]
has_stack() bool[source]

Check if data is available to export @return: True if data is available to export and False otherwise

normalise_issue() str[source]
presenter: SpectrumViewerWindowPresenter
remove_all_roi() None[source]

Remove all ROIs from the model excluding default ROI ‘all’

remove_roi(roi_name) None[source]

Remove the selected ROI from the model

@param roi_name: The name of the ROI to remove

rename_roi(old_name: str, new_name: str) None[source]

Rename the selected ROI from the model

@param old_name: The current name of the ROI @param new_name: The new name of the ROI @raises KeyError: If the ROI does not exist @raises RuntimeError: If the ROI is ‘all’

roi_name_generator() str[source]

Returns a new Unique ID for newly created ROIs

Returns:

A new unique ID

save_csv(path: Path, normalized: bool) None[source]

Iterates over all ROIs and saves the spectrum for each one to a CSV file.

@param path: The path to save the CSV file to. @param normalized: Whether to save the normalized spectrum.

save_roi_coords(path: Path) None[source]

Save the coordinates of the ROIs to a csv file (ROI name, x_min, x_max, y_min, y_max) following Pascal VOC format. @param path: The path to save the CSV file to.

set_new_roi(name: str) None[source]

Sets a new ROI with the given name

@param name: The name of the new ROI

set_normalise_stack(normalise_stack: ImageStack | None) None[source]
set_roi(roi_name: str, roi: SensibleROI)[source]
set_stack(stack: ImageStack | None) None[source]

Sets the stack to be used by the model If that stack is None, then the model will be reset If the stack has changed, then the ROI ranges will be reset and additional ROIs excluding default ROIs will be removed

@param stack: The new stack to be used by the model

tof_range: tuple[int, int] = (0, 0)