Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running stitching with only 2 axes #155

Open
lauhei opened this issue Jan 28, 2025 · 2 comments
Open

Running stitching with only 2 axes #155

lauhei opened this issue Jan 28, 2025 · 2 comments

Comments

@lauhei
Copy link

lauhei commented Jan 28, 2025

Hi,

We are trying to run rigid stitching on lightsheet data that is only 1 tile wide in the Y axis. Our workspace looks like

Workspace[CellMap]{.../S-L}
              raw: 240918_Brain-S_hemisphereL_10-07-06/10-07-06_Brain-S_hemisphereL_UltraII[00 x <X,2>]_C00_xyz-Table Z<Z,4>.ome.npy {8775 files, ('X', 'Z'): (0, 0) -> (2, 2924)}
                   240918_Brain-S_hemisphereL_10-07-06/10-07-06_Brain-S_hemisphereL_UltraII[00 x <X,2>]_C00_xyz-Table Z<Z,4>.ome.tif {8775 files, ('X', 'Z'): (0, 0) -> (2, 2924)}
 autofluorescence: 240918_Brain-S_hemisphereL_AF_19-11-36/19-11-36_Brain-S_hemisphereL_AF_UltraII[00 x <X,2>]_C00_xyz-Table Z<Z,4>.ome.tif {1952 files, ('X', 'Z'): (0, 0) -> (1, 975)}
         stitched: no file
           layout: no file
       background: no file
        resampled: no file
resampled_to_auto: no file
auto_to_reference: no file
            cells: no file
          density: no file
   tile_extension: no file
         arteries: 240918_Brain-S_hemisphereL_10-07-06/10-07-06_Brain-S_hemisphereL_UltraII[00 x <X,2>]_C02_xyz-Table Z<Z,4>.ome.npy {8775 files, ('X', 'Z'): (0, 0) -> (2, 2924)}
                   240918_Brain-S_hemisphereL_10-07-06/10-07-06_Brain-S_hemisphereL_UltraII[00 x <X,2>]_C02_xyz-Table Z<Z,4>.ome.tif {8775 files, ('X', 'Z'): (0, 0) -> (2, 2924)}

With the resulting traceback when we run rigid stitching preview or run stitching:

Traceback (most recent call last):
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/gui/tabs.py", line 436, in preview_stitching_smart
    self.wrap_step('Stitching', self.preprocessor.stitch_rigid, step_kw_args={'force': True},
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/gui/interfaces.py", line 297, in wrap_step
    self.main_window.wrap_in_thread(func, *step_args, **step_kw_args)
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/gui/run_gui.py", line 619, in wrap_in_thread
    return result.get()
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/multiprocessing/pool.py", line 771, in get
    raise self._value
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Utils/utilities.py", line 171, in wraps
    return func(*args, **kwargs)
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/processors/sample_preparation.py", line 381, in stitch_rigid
    layout = self.get_wobbly_layout(overlaps)
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Utils/utilities.py", line 171, in wraps
    return func(*args, **kwargs)
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/processors/sample_preparation.py", line 414, in get_wobbly_layout
    layout = stitching_wobbly.WobblyLayout(expression=raw_path, tile_axes=['X', 'Y'], overlaps=overlaps)
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Alignment/Stitching/StitchingWobbly.py", line 729, in __init__
    strg.TiledLayout.__init__(self, sources = sources, expression = expression, tile_axes = tile_axes, tile_shape = tile_shape, tile_positions = tile_positions, positions = positions, overlaps = overlaps, alignments = alignments, position = position, shape = shape, dtype = dtype, order = order);
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Alignment/Stitching/StitchingRigid.py", line 1910, in __init__
    sources, alignments, tile_positions = _initialize_tiles_from_expression(expression, tile_axes=tile_axes, tile_shape=tile_shape, tile_positions=tile_positions, overlaps=overlaps, positions=positions, alignments=alignments);
  File ".../miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Alignment/Stitching/StitchingRigid.py", line 2247, in _initialize_tiles_from_expression
    raise ValueError('The expression does not have the named pattern %s' % n);
ValueError: The expression does not have the named pattern Y

Is there a way to resolve this? Any advice would be greatly appreciated.

Thank you

@crousseau
Copy link
Collaborator

Hi,

this is indeed an oversight. I will include a proper fix in the future version. In the mean time, I suggest you try to edit that line:

./miniconda3/envs/ClearMapUi39clean/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/processors/sample_preparation.py", line 414, in get_wobbly_layout
layout = stitching_wobbly.WobblyLayout(expression=raw_path, tile_axes=['X', 'Y'], overlaps=overlaps)

and remove from tile_axes=['X', 'Y'] the axis that you do not use (e.g. tile_axes=['Y'] if you only use the y axis.

@lauhei Please report back to me about that fix. If it works well for you, I will offer a proper fix using the expression next week.

@lauhei
Copy link
Author

lauhei commented Feb 1, 2025

Hi,

Thank you for the advice. This change solved the initial error, but leads to a different one when trying to preview stitching:

Traceback (most recent call last):
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/gui/tabs.py", line 436, in preview_stitching_smart
    self.wrap_step('Stitching', self.preprocessor.stitch_rigid, step_kw_args={'force': True},
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/gui/interfaces.py", line 297, in wrap_step
    self.main_window.wrap_in_thread(func, *step_args, **step_kw_args)
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/gui/run_gui.py", line 619, in wrap_in_thread
    return result.get()
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/multiprocessing/pool.py", line 771, in get
    raise self._value
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Utils/utilities.py", line 171, in wraps
    return func(*args, **kwargs)
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/processors/sample_preparation.py", line 381, in stitch_rigid
    layout = self.get_wobbly_layout(overlaps)
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Utils/utilities.py", line 171, in wraps
    return func(*args, **kwargs)
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/processors/sample_preparation.py", line 414, in get_wobbly_layout
    layout = stitching_wobbly.WobblyLayout(expression=raw_path, tile_axes=['X', 'Z'], overlaps=overlaps)
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Alignment/Stitching/StitchingWobbly.py", line 735, in __init__
    self.sources = [WobblySource(source = s, axis = axis) for s in sources];
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Alignment/Stitching/StitchingWobbly.py", line 735, in <listcomp>
    self.sources = [WobblySource(source = s, axis = axis) for s in sources];
  File "./miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/Alignment/Stitching/StitchingWobbly.py", line 78, in __init__
    self._wobble = np.zeros((shape[self._axis], len(shape) - 1), dtype = int);
IndexError: tuple index out of range

We tried to fix this by changing self_axis to 1. This bypassed the error during preview stitching but led to the software freezing without an error message when trying to run stitching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants