ClearAnatomics / ClearMap

ClearMap 2 with WobblyStitcher, TubeMap and CellMap
https://clearanatomics.github.io/ClearMapDocumentation/
GNU General Public License v3.0
109 stars 46 forks source link

Z dimension not detected for preview rigid stitching #147

Open stellalessandra opened 1 month ago

stellalessandra commented 1 month ago

I am trying to stitch a large image of a Mouse Whole Brain of a single channel without autofluorescence, acquired by a LSFM, using the ClearMap GUI. I have raw tile files already converted to .npy, where the XYZ factoring is: raw/10-44-28_BL45_ctrl_cfos_UltraII[<Y,2> x <X,2>]_C00_xyz-Table Z<Z,4>.ome.tif

The workspace also shows the correct information: Workspace[CellMap]{/home/clearmap/Documents/test_cm} raw: raw/10-44-28_BL45_ctrl_cfos_UltraII[<Y,2> x <X,2>]_C00_xyz-Table Z<Z,4>.ome.npy {15180 files, ('Y', 'X', 'Z'): (0, 0, 0) -> (3, 2, 1264)} raw/10-44-28_BL45_ctrl_cfos_UltraII[<Y,2> x <X,2>]_C00_xyz-Table Z<Z,4>.ome.tif {15180 files, ('Y', 'X', 'Z'): (0, 0, 0) -> (3, 2, 1264)} autofluorescence: no file 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

However, it seems like the program is not able to acquire the Z dimension, as it gives the following error after clicking the Rigid Stitching Preview button:

Traceback (most recent call last): File "/home/clearmap/miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/gui/tabs.py", line 417, in preview_stitching_dumb overlay = [pg.image(self.preprocessor.stitch_overlay('raw', color))] File "/home/clearmap/miniconda3/envs/ClearMapUi39/lib/python3.9/site-packages/ClearMap2-2.1.4-py3.9-linux-x86_64.egg/ClearMap/processors/sample_preparation.py", line 754, in stitch_overlay middle_z = int(tile_shape['Z'] / 2) KeyError: 'Z'

I would be happy to receive any clarification on how to solve the issue. Best regards Alessandra

crousseau commented 1 month ago

Hi, @stellalessandra this is indeed currently not implemented but is planned for the next version (hopefully next month). In the mean time, you can try to stack your columns using this:

from ClearMap.IO import IO as clmio
from ClearMap.Utils.tag_expression import Expression

base_pattern = /.../raw/10-44-28_BL45_ctrl_cfos_UltraII[<Y,2> x <X,2>]_C00_xyz-Table Z<Z,4>.ome.npy   # replace ... by your source folder
exp = Expression(base_pattern)

for y in range(3):
    for x in range(2):
        column_expression = exp.string(values={'X': x, 'Y': y})
        dest = column_expression.replace('_xyz-Table Z<Z,4>', '')
        clmio.convert(column_expression, dest)