napari_dmc_brainmap.stitching package
Submodules
napari_dmc_brainmap.stitching.stitching module
DMC-BrainMap widget for stitching .tif files.
2024 - FJ, XC
- class napari_dmc_brainmap.stitching.stitching.StitchingWidget(napari_viewer: Viewer)[source]
Bases:
QWidgetQWidget for configuring and initiating the stitching process.
- progress_signal
Signal emitted to update the progress bar with an integer value.
- napari_dmc_brainmap.stitching.stitching.do_stitching(input_path: Path, filter_list: List[str], params_dict: Dict, stitch_tiles: bool, direct_sharpy_track: bool) str[source]
Perform stitching operation using input path and parameters provided.
- Parameters:
input_path (Path) – Path to directory containing data for stitching.
filter_list (List[str]) – List of channels to stitch.
params_dict (Dict) – Dictionary containing stitching parameters.
stitch_tiles (bool) – Whether to stitch individual tiles or use DMC-FluoImager data.
direct_sharpy_track (bool) – Whether to create data for SHARPy-track.
- Yields:
int – Progress value for the stitching process.
- Returns:
The animal ID for which stitching was performed.
- Return type:
str
- napari_dmc_brainmap.stitching.stitching.initialize_widget() FunctionGui[source]
Initialize the magicgui widget for stitching configuration.
Returns: FunctionGui: Initialized magicgui widget.
- napari_dmc_brainmap.stitching.stitching.load_tile_stack(in_chan: Path, stack: List[str], c_size: int = 2048) ndarray[source]
Load a stack of tiles from the specified input channel.
- Parameters:
in_chan (Path) – Input path containing tiles.
stack (List[str]) – List of tile file names.
c_size (int, optional) – Size of the tiles. Default is 2048.
Returns: np.ndarray: Loaded stack of images as a numpy array.
- napari_dmc_brainmap.stitching.stitching.process_stitch_folder(input_path: Path, in_obj: Path, f: str, stitch_dir: Path, animal_id: str, obj: str, params_dict: Dict, resolution: Tuple[int, int], direct_sharpy_track: bool, overlap: int = 205) None[source]
Process stitching for a folder of tiles.
- Parameters:
input_path (Path) – Base path to animal data.
in_obj (Path) – Input path for object data.
f (str) – Channel to process.
stitch_dir (Path) – Directory to save stitched data.
animal_id (str) – Animal ID.
obj (str) – Object name.
params_dict (Dict) – Parameters for stitching.
resolution (Tuple[int, int]) – Resolution of the atlas used for registration.
direct_sharpy_track (bool) – Whether to create SHARPy-track data directly.
overlap (int, optional) – Overlap for stitching tiles. Defaults to 205.
- napari_dmc_brainmap.stitching.stitching.process_stitch_stack(input_path: Path, in_obj: Path, f: str, stitch_dir: Path, animal_id: str, obj: str, params_dict: Dict, resolution: Tuple[int, int], direct_sharpy_track: bool, overlap: int = 205) None[source]
Process stitching for a stack of tiles.
- Parameters:
input_path (Path) – Base path to animal data.
in_obj (Path) – Input path for object data.
f (str) – Channel to process.
stitch_dir (Path) – Directory to save stitched data.
animal_id (str) – Animal ID.
obj (str) – Object name.
params_dict (Dict) – Parameters for stitching.
resolution (Tuple[int, int]) – Resolution of the atlas used for registration.
direct_sharpy_track (bool) – Whether to create SHARPy-track data directly.
overlap (int, optional) – Overlap for stitching tiles. Defaults to 205.
napari_dmc_brainmap.stitching.stitching_tools module
- napari_dmc_brainmap.stitching.stitching_tools.downsample_image(input_tiff: str | ndarray, size_tuple: Tuple[int, int], contrast_tuple: Tuple[int, int]) ndarray[source]
Downsample an image and adjust its brightness.
- Parameters:
input_tiff (Union[str, np.ndarray]) – Input image (file path or image matrix).
size_tuple (Tuple[int, int]) – Target size for downsampling.
contrast_tuple (Tuple[int, int]) – Contrast adjustment parameters.
- Returns:
Downsampled image as a NumPy array.
- Return type:
np.ndarray
- napari_dmc_brainmap.stitching.stitching_tools.fill_canvas(width: int, height: int, stitch_canvas: ndarray, loc_map: Dict[int, int], data_dict: Dict, overlap: int = 205, c_size: int = 2048, stack: bool = True) ndarray[source]
Fill the stitching canvas with image tiles.
- Parameters:
width (int) – Width of the grid.
height (int) – Height of the grid.
stitch_canvas (np.ndarray) – The canvas to be filled.
loc_map (Dict[int, int]) – Mapping of tile locations.
data_dict (Dict) – Dictionary containing image data.
overlap (int, optional) – Overlap between tiles. Defaults to 205.
c_size (int, optional) – Size of each tile. Defaults to 2048.
stack (bool, optional) – Whether to use a stack or individual sections. Defaults to True.
- Returns:
Filled stitching canvas.
- Return type:
np.ndarray
- napari_dmc_brainmap.stitching.stitching_tools.get_canvas(width: int, height: int, overlap: int = 205, c_size: int = 2048) Tuple[ndarray, Dict[int, int]][source]
Create a blank canvas and generate a tile location map for stitching.
- Parameters:
width (int) – Width of the grid.
height (int) – Height of the grid.
overlap (int, optional) – Overlap between tiles. Defaults to 205.
c_size (int, optional) – Size of each tile. Defaults to 2048.
- Returns:
Tuple containing the blank canvas and location map.
- Return type:
Tuple[np.ndarray, Dict[int, int]]
- napari_dmc_brainmap.stitching.stitching_tools.get_size_json(pos_list: List[Tuple[int, int]]) Tuple[int, int][source]
Calculate the width and height of the grid from a list of positions.
- Parameters:
pos_list (List[Tuple[int, int]]) – List of positions as tuples of (x, y).
- Returns:
Width and height of the grid.
- Return type:
Tuple[int, int]
- napari_dmc_brainmap.stitching.stitching_tools.load_meta(section_dir: Path) Dict[source]
Load metadata from a .tif file in the specified directory.
- Parameters:
section_dir (Path) – Directory containing the .tif file.
- Returns:
Metadata as a dictionary.
- Return type:
Dict
- napari_dmc_brainmap.stitching.stitching_tools.map_loc(width: int, height: int) Dict[int, int][source]
Generate a mapping of tile locations for constructing a stitched image.
- Parameters:
width (int) – Width of the grid.
height (int) – Height of the grid.
- Returns:
Dictionary mapping original tile indices to new locations.
- Return type:
Dict[int, int]
- napari_dmc_brainmap.stitching.stitching_tools.padding_for_atlas(input_array: ndarray, resolution: Tuple[int, int] | None) ndarray[source]
Apply padding to an image for atlas registration.
- Parameters:
input_array (np.ndarray) – Input image as a NumPy array.
resolution (Optional[Tuple[int, int]]) – Desired resolution for padding.
- Returns:
Padded image as a NumPy array.
- Return type:
np.ndarray
- napari_dmc_brainmap.stitching.stitching_tools.stitch_folder(section_dir: Path, overlap: int, stitched_path: Path, params: dict, chan: str, downsampled_path: Path | None = False, resolution: Tuple[int, int] | None = False) None[source]
Stitch images from a folder into a single image. :param section_dir: Directory containing the images. :type section_dir: Path :param overlap: Overlap between tiles. :type overlap: int :param stitched_path: Path to save the stitched image. :type stitched_path: Path :param params: Dictionary of parameters. :type params: dict :param chan: Channel information. :type chan: str :param downsampled_path: Path to save the downsampled image (optional). :type downsampled_path: Optional[Path] :param resolution: Resolution for padding (optional). :type resolution: Optional[Tuple[int, int]]
- napari_dmc_brainmap.stitching.stitching_tools.stitch_stack(pos_list: List[Tuple[int, int]], whole_stack: ndarray, overlap: int, stitched_path: str, params: dict, chan: str, downsampled_path: Path | None = False, resolution: Tuple[int, int] | None = False) None[source]
Stitch a stack of images into a single image. :param pos_list: List of positions as tuples of (x, y). :type pos_list: List[Tuple[int, int]] :param whole_stack: Stack of images to be stitched. :type whole_stack: np.ndarray :param overlap: Overlap between tiles. :type overlap: int :param stitched_path: Path to save the stitched image. :type stitched_path: str :param params: Dictionary of parameters. :type params: dict :param chan: Channel information. :type chan: str :param downsampled_path: Path to save the downsampled image (optional). :type downsampled_path: Optional[Path] :param resolution: Resolution for padding (optional). :type resolution: Optional[Tuple[int, int]]