ClearAnatomics / ClearMap

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

struct.error: 'i' format requires -2147483648 <= number <= 2147483647 #37

Closed saskra closed 4 years ago

saskra commented 4 years ago

As I cannot (and need not) run a whole brain on my current machine I wanted to try those parts I need and where I expect your code to be faster than the one I previously used. I could confirm this for the skeletonization which works really well. But I am stuck with the segmentation/ binarization. This is my code using your function:

import time

import numpy as np

import ClearMap.IO.IO as io
import ClearMap.ImageProcessing.Experts.Vasculature as vasc

binarization_parameter = vasc.default_binarization_parameter.copy()
processing_parameter = vasc.default_binarization_processing_parameter.copy()
processing_parameter.update(as_memory=True)

file = "14-16-41_tricocktail_UltraII[03 x 06]_C00_UltraII Filter0000.ome.tif"
source = io.read(file)
sink = "seg_" + "".join(filter(str.isalnum, file.split('.')[0]))
print(sink)

start_time = time.time()
im_seg = vasc.binarize(source, sink + ".npy",
                       binarization_parameter=binarization_parameter,
                       processing_parameter=processing_parameter)
elapsed_time = time.time() - start_time
print(elapsed_time)

im_seg.array = im_seg.array.astype(np.uint8) * 255
io.write(sink + ".tif", im_seg)

And this is the error message:

Traceback (most recent call last):
  File "/home/saskra/anaconda3/envs/ClearMap_II/lib/python3.6/multiprocessing/queues.py", line 240, in _feed
    send_bytes(obj)
  File "/home/saskra/anaconda3/envs/ClearMap_II/lib/python3.6/multiprocessing/connection.py", line 200, in send_bytes
    self._send_bytes(m[offset:offset + size])
  File "/home/saskra/anaconda3/envs/ClearMap_II/lib/python3.6/multiprocessing/connection.py", line 393, in _send_bytes
    header = struct.pack("!i", n)
struct.error: 'i' format requires -2147483648 <= number <= 2147483647

Any idea how to fix that, some parameter settings maybe?

saskra commented 4 years ago

OK, there seems to be an easy solution: Do not read the file in advance, just enter the path in the function call. And you have to convert Tif to Npy if your file is bigger than ~4GB.