11"""
2- EpiCure main.
2+ Load intensity movie from napari layer and extract metadata.
3+ Handles various image formats (2D, 3D, 4D) with different dimension orders.
4+ Supports temporal, channel, and z-stack dimensions.
5+ layer: napari layer object with image data and scale information
6+ imgpath (str): File path to the image
7+ tuple: (caxis, cval) where caxis is channel axis index or None,
8+ cval is number of channels or 0
9+ - Resets internal state via reset()
10+ - Updates epi_metadata with MovieFile and ScaleXY
11+ - Sets img and mov attributes
12+ - Renames layer to "Movie", removes existing Movie layer
13+ - Updates imgshape, imgshape2D, nframes
14+ **EpiCure main class.**
315
416 Open and initialize the files.
5-
6- Launch the main widget composed of the segmentation and tracking editing features
17+ Launch the main widget composed of the segmentation and tracking editing features.
18+ All other classes are linked to this one.
719"""
820import numpy as np
921import os , time , pickle
2840
2941class EpiCure :
3042 def __init__ (self , viewer = None ):
43+ """
44+ Initialize the EpiCure viewer instance.
45+
46+ :param: viewer (napari.Viewer, optional): An existing napari Viewer instance to use.
47+ If None, a new Viewer instance will be created with show=False.
48+ Defaults to None.
49+ """
3150 self .viewer = viewer
51+ """ Napari viewer that is used for this session """
3252 if self .viewer is None :
3353 self .viewer = napari .Viewer (show = False )
3454 self .viewer .title = "Napari - EpiCure"
3555 self .reset ()
3656
3757 def reset (self ):
38- """ Reset parameters """
58+ """ Reset all the parameters to the default values """
3959 self .init_epicure_metadata () ## initialize metadata variables (scalings, channels)
4060 self .img = None
61+ """ data of the raw movie """
4162 self .inspecting = None
63+ """ interface for inspection options """
4264 self .others = None
4365 self .imgshape2D = None ## width, height of the image
4466 self .nframes = None ## Number of time frames
@@ -70,7 +92,7 @@ def reset(self):
7092
7193
7294 def init_epicure_metadata (self ):
73- """Returns metadata to save """
95+ """ Fills metadata with default values """
7496 ## scalings and unit names
7597 self .epi_metadata = {}
7698 self .epi_metadata ["ScaleXY" ] = 1
@@ -95,11 +117,34 @@ def get_resetbtn_color(self):
95117 return None
96118
97119 def set_thickness (self , thick ):
98- """Thickness of junctions (half thickness)"""
120+ """
121+ Thickness of junctions (half thickness)
122+
123+ :param: thick set thickness value to input value
124+ """
99125 self .thickness = thick
100126
101127 def movie_from_layer (self , layer , imgpath ):
102- """Prepare the intensity movie from opened layer, and get metadata"""
128+ """
129+ Prepare the intensity movie from opened layer, and get metadata.
130+
131+ Resets the internal state, loads image data from the provided layer,
132+ handles temporal and channel dimensions, and prepares the movie for processing.
133+
134+ It extracts metadata including file path and pixel scale, and attempts to handle various
135+ image formats (2D, 3D, 4D with different dimension orders).
136+
137+ :param: layer: A napari layer object containing the image data and scale information.
138+ The layer's data attribute should contain the image array.
139+ :param: imgpath (str): Absolute or relative file path to the image file being loaded.
140+
141+ :return:
142+ A tuple containing:
143+ - caxis (int or None): The axis index corresponding to the channel dimension,
144+ or None if no multiple channels are detected.
145+ - cval (int): The number of channels found in the image, or 0 if no channels
146+ are detected.
147+ """
103148 self .reset () ## reload everything
104149 self .epi_metadata ["MovieFile" ] = os .path .abspath (imgpath )
105150 ## if the layer is scaled, should be the right scale
@@ -137,7 +182,11 @@ def movie_from_layer(self, layer, imgpath):
137182
138183
139184 def load_movie (self , imgpath ):
140- """Load the intensity movie, and get metadata"""
185+ """
186+ Load the intensity movie, and get metadata
187+
188+ :param: imgpath: full path to where the movie file is
189+ """
141190 self .reset () ## reload everything
142191 self .epi_metadata ["MovieFile" ] = os .path .abspath (imgpath )
143192 self .img , nchan , self .epi_metadata ["ScaleXY" ], self .epi_metadata ["UnitXY" ], self .epi_metadata ["ScaleT" ], self .epi_metadata ["UnitT" ] = ut .open_image (
@@ -173,6 +222,7 @@ def load_movie(self, imgpath):
173222
174223
175224 def quantiles (self ):
225+ """ Returns the quantiles 1% and 99.999% of the raw image to set the display """
176226 return tuple (np .quantile (self .img , [0.01 , 0.9999 ]))
177227
178228 def set_verbose (self , verbose ):
@@ -181,7 +231,10 @@ def set_verbose(self, verbose):
181231 self .epi_metadata ["Verbose" ] = verbose
182232
183233 def set_gaps_option (self , allow_gap ):
184- """Set the mode for gap allowing/forbid in tracks"""
234+ """Set the mode for gap allowing/forbid in tracks
235+
236+ :param: allow_gap: boolean. Indicates if gap in tracks (missing cell in one or more frames) should be allowed or not.
237+ """
185238 self .epi_metadata ["Allow gaps" ] = allow_gap
186239 self .forbid_gaps = not allow_gap
187240
0 commit comments