magellanmapper icon indicating copy to clipboard operation
magellanmapper copied to clipboard

z-Dimension Error in "merge_atlas_segs" step

Open SaibotMagd opened this issue 3 years ago • 1 comments

Next: step 6 in Protocol 5 on a 2D image gave me this error:

root - INFO - original shape: (0, 839, 1416), new shape: [   0  839 1416]
root - INFO - start: 0, end: None, remaining_planes: 0, tot_planes: 0
root - INFO - Checking labels symmetry after mirroring:
root - INFO - halves symmetric along axis 0? True
root - INFO - same labels in each half? True
root - INFO - cropping to original labels' extent with filter size of 1
root - ERROR - multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/home/tgottsch/anaconda3/envs/mag/lib/python3.6/multiprocessing/pool.py", line 119, in worker
    result = (True, func(*args, **kwds))
  File "/home/tgottsch/Atlas_project/magellanmapper/magmap/atlas/edge_seg.py", line 323, in edge_aware_segmentation
    labels_img_np, labels_seg, crop)
  File "/home/tgottsch/Atlas_project/magellanmapper/magmap/atlas/atlas_refiner.py", line 658, in crop_to_orig
    labels_img_np[mask] = 0
IndexError: boolean index did not match indexed array along dimension 0; dimension is 0 but corresponding boolean dimension is 1

Its connected to z being 0. When I process this step on a cloned 2D image it works but it seems like he's doubling the borderlines. I don't understand what the algorithm is doing, but obviously he's using information of the next slice similar to the edg detection step.

image

The result of make_edge_images and merge_atlas_segs are the same. So this step seems to do nothing on my data.

So this is the situation I'm facing at the moment:

  • I can't edge_detect my whole 3D stack (as far as we know it's because the differences between the slices are to big)
  • I can't merge_atlas_segs aka erode labels to core -> regrow to fit anatomical edges because it doesn't work on 2D images

Possible solution:

  • do the edge_detection step individually for each 2D image
  • merge all the resulted 2D images together (dist, volume, annotation)
  • perform the merge_atlas_segs onto the manual created 3D stack

SaibotMagd avatar Apr 27 '21 10:04 SaibotMagd

Thanks for reporting this, @SaibotMagd!

The annotationDist and annotationEdge files aren't actually used in the rest of the pipeline, so it may be ok if they don't quite work. For the error, you could try turning off the crop_to_orig function by using the nocroplabels profile (eg using the --atlas_profile nocroplabels command-line option...hopefully I haven't made any typos this time!). This will skip the step that crops out unlabeled signal in the intensity image and just leave it as-is.

do the edge_detection step individually for each 2D image

This may work. If the anatomical edge (atlasEdge) image looks fine, the labels can be remolded into those boundaries, especially if you have 3D anatomical edges (eg if the intensity image is whole-brain).

perform the merge_atlas_segs onto the manual created 3D stack

This may also work. Just requires manually making a rough approximation of labels in the in-between planes beforehand (or could try interpolating each label with the GUI if that saves time), then remolding those labels with the pipeline.

yoda-vid avatar Apr 28 '21 11:04 yoda-vid