Dataset

class morphonet.data.dataset.DatasetAnalysis(ds, override_temp_path=None)

Bases: object

The dataset is the class that represent a MorphoNet local dataset in temporary files. Loading the dataset in memory can be really long

compute_region_property(property_name, step=-1, ch=0)

Compute the region property for all available steps, for all time points. The computed region properties will be saved to a temporary folder for MorphoNet.

Parameters:
  • property_name (str) – Name of the property

  • step (int) – step to find the property version, -1 for last step

  • ch (int) – channel index for the property computation

Returns:

Property computed

Return type:

ScikitProperty

compute_region_property_at(property_name, time, step=-1, ch=0)

Compute the region property for a given step, at given time point. The computed region properties will be saved to a temporary folder for MorphoNet.

Parameters:
  • property_name (str) – Name of the property

  • time (int) – time point

  • step (int) – step to find the property version, -1 for last step

  • ch (int) – channel index for the property computation

Returns:

segmentation image array corresponding to time point and channel, for step

Return type:

ScikitProperty

compute_regionproperty_all_steps(property_name, ch=0, save=True)

Compute the region property for all available steps, for all time points. The computed region properties will be saved to a temporary folder for MorphoNet.

Parameters:
  • property_name (str) – Name of the property

  • ch (int) – channel index for the property computation

  • save (bool) – should save the property to file? (optional, default is True)

Returns:

Property computed

Return type:

ScikitProperty

delete_region_properties(step=-1, ch=0)

Delete all region properties for a given step, for all time points.

Parameters:
  • step (int) – step to find the property version, -1 for last step

  • ch (int) – channel index for the property computation

delete_region_properties_all_steps(ch=0)

Delete all region property at all steps, for all time points.

Parameters:
  • property_name (str) – Name of the property

  • ch (int) – channel index for the property computation

delete_region_properties_at(time, step=-1, ch=0)

Delete all region properties for a given step, at given time point.

Parameters:
  • time (int) – time point

  • step (int) – step to find the property version, -1 for last step

  • ch (int) – channel index for the property computation

delete_region_property(property_name, step=-1, ch=0)

Delete a region property for a given step, for all time points.

Parameters:
  • step (int) – step to find the property version, -1 for last step

  • ch (int) – channel index for the property computation

delete_region_property_all_steps(property_name, ch=0)

Delete a region property at all steps, for all time points.

Parameters:
  • property_name (str) – Name of the property

  • ch (int) – channel index for the property computation

delete_region_property_at(property_name, time, step=-1, ch=0)

Delete a region property for a given step, at given time point.

Parameters:
  • time (int) – time point

  • step (int) – step to find the property version, -1 for last step

  • ch (int) – channel index for the property computation

export_dataset_at_step(channel, segmentation_folder_output, image_format=None, step=-1)

Export all segmentations of the dataset at step (if -1, last step found), into a folder with a specific format

Parameters:
  • channel (int) – Channel in the segmentation

  • segmentation_folder_output (str) – Folder where the segmentation images will be exported

  • step (int) – Step to export the dataset from

export_image(time, channel, export_folder, step=-1, image_file_type='.nii.gz')

Extract the segmentation image found at given step , channel and time, and save it to image path

Parameters:
  • time (int) – Time in the segmentation

  • channel (int) – Channel in the segmentation

  • export_folder (str) – Path where the image should be stored

  • step (int) – Step to export the dataset from

export_properties_as_txt(output_folder, step=-1)

Export all properties from the dataset as text files

Parameters:
  • output_folder (str) – Folder where property texts will be generated

  • step (int) – Step to export the dataset from, -1 for last step

export_properties_as_xml(output_file, step=-1)

Export all properties from the dataset as a XML file

Parameters:
  • output_file (str) – Property file that will be generated

  • step (int) – Step to export the dataset from, -1 for last step

find_properties_path_at_step(current_step)

Find all properties file path for property in current_step, can include scikit properties or not. If not found, return empty list.

Parameters:

current_step (int) – step to search in

Returns:

list of paths to properties file

Return type:

list

find_property_path_at_step(property_name, current_step=-1)

Returns the path to the last updated property file for a given name, for a given step. (search will be done from given step to 0 returning the first found) Time can be added, if time is not specified, returns the last step found for the curation name. If specified,

Parameters:

property_name (str) – property name

Current_step:

Current step

Returns:

The path to property file

Return type:

str

find_segmentation_path_at_step(step, t, ch=0)

Returns the path to the last updated segmentation temporary file for a given time , channel (search will be done from given step to 0 , returning the first found)

Parameters:
  • t (int) – Time point

  • ch (int) – Channel

  • step (int) – Current step

Returns:

Path to the last updated segmentation temporary file

Return type:

str

get_action_at(step=-1)

Read the content of the action file for the step given in parameter. If step is -1, returns the action for last step

Parameters:

step (int) – number of the step of curation, if -1 , use the last step

Returns:

action file content or None

Return type:

str

get_all_properties(step=-1)

Returns all properties found at step parameter, including all steps before. If step is -1, returns all properties at last step.

Parameters:

step (int) – step to search. If -1 or not specified, search for last step

Returns:

all properties found at step parameter

Return type:

dict

get_cells_updated_at(step=-1)

Read the content of the action file for the step given in parameter, and returns the cell updated. If step is -1, returns the action cell list for last step

Parameters:

step (int) – Step of curation, if -1, use the last step

Returns:

list of cell ids content or None

Return type:

list of str

get_cells_updated_by_selection_at(step=-1)

Read the content of the action file for the step given in parameter, and returns the cell updated, grouping them by selection. If step is -1, returns the action cell list for last step

Parameters:

step (int) – number of the step of curation, if -1 , use the last step

Returns:

dict of cell ids content by selection or None

Return type:

dict

get_last_step()

Returns the last step key found for the dataset

Returns:

last step

Return type:

int

get_max_time()

Returns the dataset max time point

Returns:

max time point

Return type:

int

get_min_time()

Returns the dataset min time point

Returns:

min time point

Return type:

int

get_name()

Returns the dataset name

Returns:

name

Return type:

string

get_number_of_curations()

Read the temp folders of the dataset, and count the number of steps

Returns:

Number of curation steps

Return type:

int

get_plugin_name_at(step=-1)

Read the plugin from the action file for the step given in parameter. If step is -1, returns the action for last step

Parameters:

step (int) – number of the step of curation, if -1 , use the last step

Returns:

plugin found in action file content or None

Return type:

str

get_plugin_parameters_at(step=-1)

Read the plugin from the action file for the step given in parameter. If step is -1, returns the action for last step

Parameters:

step (int) – number of the step of curation, if -1 , use the last step

Returns:

plugin found in action file content or None

Return type:

str

get_property(property_name, step=-1)

Return the property object at given step. If step is -1, find in last step The time point parameter is only used loading a scikit properties

Parameters:
  • property_name (str) – Name of the property

  • step (int) – step to find the property version, -1 for last step

Returns:

Property found

Return type:

MorphoNet.Property

get_property_at(property_name, time, step=-1)

Return the property find by name, corresponding to time point, and step if step is -1, the function finds the image in.

Parameters:
  • property_name (str) – Name of the property

  • time (int) – time point

  • step (int) – step to find the property version, -1 for last step

Returns:

segmentation image array corresponding to time point and channel, for step

Return type:

MorphoNet.Property

get_property_at_time_step(property_name, step, time)

Return the property find by name, corresponding to time point, and step.

Parameters:
  • property_name (str) – Name of the property

  • time (int) – time point

  • step (int) – step to find the property version, -1 for last step

Returns:

segmentation image array corresponding to time point and channel, for step

Return type:

MorphoNet.Property

get_property_step_before(property_name, step=-1)

Retrieve the last step containing the property given by name. Time can be added, if time is not specified, returns the last step found for the curation name. If specified,

Parameters:

property_name (str) – property name

Returns:

the step value

Return type:

int

get_region_properties_step_before(time, channel, step=-1)

Retrieve the last step containing the property given by name. Time can be added, if time is not specified, returns the last step found for the curation name. If specified, will find the last step for a scikit property at given time

Parameters:

property_name (str) – property name

Returns:

the step value

Return type:

int

get_region_property(property_name, step=-1)

Return a region property for a specific step :param property_name: :type property_name: (str) property to return :param step: :type step: step to get (-1 means last step)

Return type:

The property found, or None if it does not exist

get_region_property_at(property_name, time, step=-1)

Return a region property for a specific step and time point :param property_name: :type property_name: (str) property to return :param time: :type time: (int) time to get :param step: :type step: (int) step to get (-1 means last step)

Return type:

The property found, or None if it does not exist

get_region_property_at_time_step(property_name, step, time)

Return the property find by name, corresponding to time point, and step.

Parameters:
  • property_name (str) – Name of the property

  • time (int) – time point

  • step (int) – step to find the property version, -1 for last step

Returns:

segmentation image array corresponding to time point and channel, for step

Return type:

ScikitProperty

get_segmentation_at_step(time, channel=0, step=-1)

Return the segmentation specified object by time,channel at a specific given step. If load_array is set to False, the image content will not be loaded into the segmentation object

Parameters:
  • time (int) – time point

  • step (int) – step

  • channel (int) – channel

Returns:

segmentation array

Return type:

np.ndarray

get_segmentation_step_before(time, channel=0, step=-1)

Returns the last step where a segmentation (found by channel, time) has been updated

Parameters:
  • time (int) – Time point

  • channel (int) – Channel

Returns:

Last step

Return type:

int

get_updated_properties(step=-1)

Returns all properties found at step parameter. If step is -1, returns all properties at last step.

Parameters:

step (int) – step to search. If -1 or not specified, search for last step

Returns:

all properties found at step parameter

Return type:

dict

list_all_properties()

List all properties available in the dataset

Returns:

all properties found at step parameter

Return type:

dict

load_properties_at_step(step=-1)

Returns the path to the last updated property file for a given name, for a given step. (search will be done from given step to 0 returning the first found) Time can be added, if time is not specified, returns the last step found for the curation name. If specified,

Step:

Current step

Returns:

The path to property file

Return type:

str

print_computable_region_properties()

Print all properties that can be computed using compute_property commands

write_property_to_step(step, property_object)

Save a given dictionary to a morphonet text format property. Giving a type to the information is important

Parameters:
  • step (int) – Step to write in, it has to exist

  • property_object (MorphoNet.Property) – MorphoNet property object to save

write_segmentation_to_step(step, segmentation_array, time, channel)

Save a given segmentation to the step folder, and update step action file

Parameters:
  • step (int) – The step to write in

  • segmentation_array (ndarray) – Array of the segmentation image

  • time (int) – Time point of the segmentation

  • channel (int) – Channel of the segmentation