When I run RESPAN on an image with a large number of dendrites (such as those labeled in the superficial layers of the cortex) the program throws an error citing memory overload.
Log Below:
##Raw Image: 1.1M_+-M_L23_PN2_ApicalT1.tif & Label Image: 1.1M+-_M_L23_PN2_ApicalT1.tif
2026-03-25 14:25:19,254 - INFO - Raw shape: (131, 1292, 1871) & Labels shape: (131, 1292, 1871)
2026-03-25 14:25:19,255 - INFO - Raw image size: 0.633 GB
2026-03-25 14:25:19,255 - INFO - The neuron channel for this image is ~0.32 GB in size. This may take considerable time to process.
2026-03-25 14:25:19,256 - INFO - Estimated processing time is ~8.0 minutes, depending on computational resources.
2026-03-25 14:25:20,365 - INFO - Filtering dendrites...
2026-03-25 14:25:36,102 - INFO - Processing 58 of 545 detected dendrites larger than minimum volume threshold of 1176.0 voxels
2026-03-25 14:25:36,166 - INFO - Calculating distances from dendrites...
2026-03-25 14:25:36,351 - INFO - Using scale factor 4.0 to reduce computation time for adaptive distance calculation.
2026-03-25 14:25:46,836 - INFO - Time taken for adaptive distance calculation: 10.52 seconds
2026-03-25 14:25:46,850 - INFO - Calculating dendrite skeleton...
2026-03-25 14:25:54,532 - INFO - Time taken for initial processing: 35.28 seconds
2026-03-25 14:25:54,534 - INFO - Analyzing spines...
2026-03-25 14:25:54,535 - INFO - Using model type Dendrites, Spine Cores, Spine Membranes, Necks, Soma, and Axons
2026-03-25 14:25:54,536 - INFO - Analyzing spines using cores and membranes...
2026-03-25 14:26:30,127 - INFO - Voxels unassigned to spines: 310.
2026-03-25 14:26:30,201 - INFO - [spine_detection_cores_and_membranes] ΔRAM 1.181 GB ΔGPU 0.0 GB
RAM 8.302 GB GPU 1.537 GB 35.66s
2026-03-25 14:26:30,201 - INFO - [spine_detection_cores_and_membranes] top10: {'labeled_dendrites': '1.18 GB (131, 1292, 1871)', 'dendrite_distance': '1.18 GB (131, 1292, 1871)', 'neuron': '0.59 GB (131, 1292, 1871)', 'image': '0.59 GB (131, 1, 1292, 1871)', 'spines': '0.295 GB (131, 1292, 1871)', 'spine_membranes': '0.295 GB (131, 1292, 1871)', 'spine_cores': '0.295 GB (131, 1292, 1871)', 'soma_distance': '0.295 GB (131, 1292, 1871)', 'soma': '0.295 GB (131, 1292, 1871)', 'skeleton': '0.295 GB (131, 1292, 1871)'}
2026-03-25 14:26:30,351 - INFO - Making initial morphology and intensity measurements for channel 1...
2026-03-25 14:26:30,857 - INFO - Measuring distances to dendrite/s...
2026-03-25 14:26:31,327 - INFO - Total putative spines: 1765
2026-03-25 14:26:31,328 - INFO - Spines after volume filtering = 1234
2026-03-25 14:26:31,330 - INFO - Spines after distance filtering = 1223
2026-03-25 14:26:39,109 - INFO - [initial_spine_measurements] ΔRAM 1.18 GB ΔGPU 0.0 GB
RAM 9.481 GB GPU 1.537 GB 8.76s
2026-03-25 14:26:39,110 - INFO - [initial_spine_measurements] top10: {'spine_labels': '1.18 GB (131, 1292, 1871)', 'labeled_dendrites': '1.18 GB (131, 1292, 1871)', 'dendrite_distance': '1.18 GB (131, 1292, 1871)', 'neuron': '0.59 GB (131, 1292, 1871)', 'image': '0.59 GB (131, 1, 1292, 1871)', 'spines': '0.295 GB (131, 1292, 1871)', 'spine_membranes': '0.295 GB (131, 1292, 1871)', 'spine_cores': '0.295 GB (131, 1292, 1871)', 'soma_distance': '0.295 GB (131, 1292, 1871)', 'soma': '0.295 GB (131, 1292, 1871)'}
2026-03-25 14:26:39,255 - INFO - Time taken for initial spine detection: 8.90 seconds
2026-03-25 14:26:39,256 - INFO -
Calculating spine necks...
2026-03-25 14:26:39,256 - INFO - Image shape is (131, 1292, 1871). Neck analysis has been disabled.
2026-03-25 14:26:39,391 - INFO - Time taken for neck generation: 0.14 seconds
2026-03-25 14:26:39,393 - INFO - Calculating neuron statistics...
2026-03-25 14:26:40,327 - INFO - Calculating dendrite statistics...
2026-03-25 14:26:43,516 - INFO - Complete.
2026-03-25 14:26:43,518 - INFO - Calculating spine dendrite ID and geodesic distance...
2026-03-25 14:28:34,256 - INFO - Complete.
2026-03-25 14:28:34,258 - INFO -
Performing additional mesh measurements on spines in batches on GPU...
2026-03-25 14:28:34,309 - INFO - Max ID for spines filtered is 1764
2026-03-25 14:28:34,409 - INFO - Max ID for connected necks is 0
2026-03-25 14:28:35,278 - INFO - Total memory required for full multi-channel array: 5.07 GB
2026-03-25 14:28:35,279 - INFO - Total available GPU memory: 24.11 GB. Percentage of GPU memory required for array: 21.02%
2026-03-25 14:28:36,014 - INFO - Multi-channel GPU array created.
2026-03-25 14:28:36,182 - INFO - Using batch size of 131 spines...
2026-03-25 14:28:36,183 - INFO - Processing batch 1 of 10... (10% complete)
2026-03-25 14:28:39,951 - ERROR - An error occurred: Out of memory allocating 41,483,834,880 bytes (allocated so far: 5,700,069,376 bytes).
Traceback (most recent call last):
File "Scripts\RESPAN_GUI_DIST.py", line 1453, in run
File "ImageAnalysis\ImageAnalysis.py", line 244, in analyze_spines
File "ImageAnalysis\MemProfiler.py", line 93, in wrapper
File "ImageAnalysis\ImageAnalysis.py", line 515, in spine_and_whole_neuron_processing
File "ImageAnalysis\MemProfiler.py", line 93, in wrapper
File "ImageAnalysis\ImageAnalysis.py", line 1243, in analyze_spines_batch
File "ImageAnalysis\ImageAnalysis.py", line 2532, in extract_subvolumes_mulitchannel_GPU_batch
File "cupy_core\core.pyx", line 1193, in cupy._core.core._ndarray_base.richcmp
File "cupy_core_routines_logic.pyx", line 32, in cupy._core._routines_logic._ndarray_equal
File "cupy_core_kernel.pyx", line 1350, in cupy._core._kernel.ufunc.call
File "cupy_core_kernel.pyx", line 645, in cupy._core._kernel._get_out_args_from_optionals
File "cupy_core\core.pyx", line 2811, in cupy._core.core._ndarray_init
File "cupy_core\core.pyx", line 241, in cupy._core.core._ndarray_base._init_fast
File "cupy\cuda\memory.pyx", line 738, in cupy.cuda.memory.alloc
File "cupy\cuda\memory.pyx", line 1424, in cupy.cuda.memory.MemoryPool.malloc
File "cupy\cuda\memory.pyx", line 1445, in cupy.cuda.memory.MemoryPool.malloc
File "cupy\cuda\memory.pyx", line 1116, in cupy.cuda.memory.SingleDeviceMemoryPool.malloc
File "cupy\cuda\memory.pyx", line 1137, in cupy.cuda.memory.SingleDeviceMemoryPool._malloc
File "cupy\cuda\memory.pyx", line 1382, in cupy.cuda.memory.SingleDeviceMemoryPool._try_malloc
File "cupy\cuda\memory.pyx", line 1385, in cupy.cuda.memory.SingleDeviceMemoryPool._try_malloc
cupy.cuda.memory.OutOfMemoryError: Out of memory allocating 41,483,834,880 bytes (allocated so far: 5,700,069,376 bytes).
2026-03-25 14:28:40,163 - INFO - An error occurred.##
When I run RESPAN on an image with a large number of dendrites (such as those labeled in the superficial layers of the cortex) the program throws an error citing memory overload.
Log Below:
##Raw Image: 1.1M_+-M_L23_PN2_ApicalT1.tif & Label Image: 1.1M+-_M_L23_PN2_ApicalT1.tif
2026-03-25 14:25:19,254 - INFO - Raw shape: (131, 1292, 1871) & Labels shape: (131, 1292, 1871)
2026-03-25 14:25:19,255 - INFO - Raw image size: 0.633 GB
2026-03-25 14:25:19,255 - INFO - The neuron channel for this image is ~0.32 GB in size. This may take considerable time to process.
2026-03-25 14:25:19,256 - INFO - Estimated processing time is ~8.0 minutes, depending on computational resources.
2026-03-25 14:25:20,365 - INFO - Filtering dendrites...
2026-03-25 14:25:36,102 - INFO - Processing 58 of 545 detected dendrites larger than minimum volume threshold of 1176.0 voxels
2026-03-25 14:25:36,166 - INFO - Calculating distances from dendrites...
2026-03-25 14:25:36,351 - INFO - Using scale factor 4.0 to reduce computation time for adaptive distance calculation.
2026-03-25 14:25:46,836 - INFO - Time taken for adaptive distance calculation: 10.52 seconds
2026-03-25 14:25:46,850 - INFO - Calculating dendrite skeleton...
2026-03-25 14:25:54,532 - INFO - Time taken for initial processing: 35.28 seconds
2026-03-25 14:25:54,534 - INFO - Analyzing spines...
2026-03-25 14:25:54,535 - INFO - Using model type Dendrites, Spine Cores, Spine Membranes, Necks, Soma, and Axons
2026-03-25 14:25:54,536 - INFO - Analyzing spines using cores and membranes...
2026-03-25 14:26:30,127 - INFO - Voxels unassigned to spines: 310.
2026-03-25 14:26:30,201 - INFO - [spine_detection_cores_and_membranes] ΔRAM 1.181 GB ΔGPU 0.0 GB
RAM 8.302 GB GPU 1.537 GB 35.66s
2026-03-25 14:26:30,201 - INFO - [spine_detection_cores_and_membranes] top10: {'labeled_dendrites': '1.18 GB (131, 1292, 1871)', 'dendrite_distance': '1.18 GB (131, 1292, 1871)', 'neuron': '0.59 GB (131, 1292, 1871)', 'image': '0.59 GB (131, 1, 1292, 1871)', 'spines': '0.295 GB (131, 1292, 1871)', 'spine_membranes': '0.295 GB (131, 1292, 1871)', 'spine_cores': '0.295 GB (131, 1292, 1871)', 'soma_distance': '0.295 GB (131, 1292, 1871)', 'soma': '0.295 GB (131, 1292, 1871)', 'skeleton': '0.295 GB (131, 1292, 1871)'}
2026-03-25 14:26:30,351 - INFO - Making initial morphology and intensity measurements for channel 1...
2026-03-25 14:26:30,857 - INFO - Measuring distances to dendrite/s...
2026-03-25 14:26:31,327 - INFO - Total putative spines: 1765
2026-03-25 14:26:31,328 - INFO - Spines after volume filtering = 1234
2026-03-25 14:26:31,330 - INFO - Spines after distance filtering = 1223
2026-03-25 14:26:39,109 - INFO - [initial_spine_measurements] ΔRAM 1.18 GB ΔGPU 0.0 GB
RAM 9.481 GB GPU 1.537 GB 8.76s
2026-03-25 14:26:39,110 - INFO - [initial_spine_measurements] top10: {'spine_labels': '1.18 GB (131, 1292, 1871)', 'labeled_dendrites': '1.18 GB (131, 1292, 1871)', 'dendrite_distance': '1.18 GB (131, 1292, 1871)', 'neuron': '0.59 GB (131, 1292, 1871)', 'image': '0.59 GB (131, 1, 1292, 1871)', 'spines': '0.295 GB (131, 1292, 1871)', 'spine_membranes': '0.295 GB (131, 1292, 1871)', 'spine_cores': '0.295 GB (131, 1292, 1871)', 'soma_distance': '0.295 GB (131, 1292, 1871)', 'soma': '0.295 GB (131, 1292, 1871)'}
2026-03-25 14:26:39,255 - INFO - Time taken for initial spine detection: 8.90 seconds
2026-03-25 14:26:39,256 - INFO -
Calculating spine necks...
2026-03-25 14:26:39,256 - INFO - Image shape is (131, 1292, 1871). Neck analysis has been disabled.
2026-03-25 14:26:39,391 - INFO - Time taken for neck generation: 0.14 seconds
2026-03-25 14:26:39,393 - INFO - Calculating neuron statistics...
2026-03-25 14:26:40,327 - INFO - Calculating dendrite statistics...
2026-03-25 14:26:43,516 - INFO - Complete.
2026-03-25 14:26:43,518 - INFO - Calculating spine dendrite ID and geodesic distance...
2026-03-25 14:28:34,256 - INFO - Complete.
2026-03-25 14:28:34,258 - INFO -
Performing additional mesh measurements on spines in batches on GPU...
2026-03-25 14:28:34,309 - INFO - Max ID for spines filtered is 1764
2026-03-25 14:28:34,409 - INFO - Max ID for connected necks is 0
2026-03-25 14:28:35,278 - INFO - Total memory required for full multi-channel array: 5.07 GB
2026-03-25 14:28:35,279 - INFO - Total available GPU memory: 24.11 GB. Percentage of GPU memory required for array: 21.02%
2026-03-25 14:28:36,014 - INFO - Multi-channel GPU array created.
2026-03-25 14:28:36,182 - INFO - Using batch size of 131 spines...
2026-03-25 14:28:36,183 - INFO - Processing batch 1 of 10... (10% complete)
2026-03-25 14:28:39,951 - ERROR - An error occurred: Out of memory allocating 41,483,834,880 bytes (allocated so far: 5,700,069,376 bytes).
Traceback (most recent call last):
File "Scripts\RESPAN_GUI_DIST.py", line 1453, in run
File "ImageAnalysis\ImageAnalysis.py", line 244, in analyze_spines
File "ImageAnalysis\MemProfiler.py", line 93, in wrapper
File "ImageAnalysis\ImageAnalysis.py", line 515, in spine_and_whole_neuron_processing
File "ImageAnalysis\MemProfiler.py", line 93, in wrapper
File "ImageAnalysis\ImageAnalysis.py", line 1243, in analyze_spines_batch
File "ImageAnalysis\ImageAnalysis.py", line 2532, in extract_subvolumes_mulitchannel_GPU_batch
File "cupy_core\core.pyx", line 1193, in cupy._core.core._ndarray_base.richcmp
File "cupy_core_routines_logic.pyx", line 32, in cupy._core._routines_logic._ndarray_equal
File "cupy_core_kernel.pyx", line 1350, in cupy._core._kernel.ufunc.call
File "cupy_core_kernel.pyx", line 645, in cupy._core._kernel._get_out_args_from_optionals
File "cupy_core\core.pyx", line 2811, in cupy._core.core._ndarray_init
File "cupy_core\core.pyx", line 241, in cupy._core.core._ndarray_base._init_fast
File "cupy\cuda\memory.pyx", line 738, in cupy.cuda.memory.alloc
File "cupy\cuda\memory.pyx", line 1424, in cupy.cuda.memory.MemoryPool.malloc
File "cupy\cuda\memory.pyx", line 1445, in cupy.cuda.memory.MemoryPool.malloc
File "cupy\cuda\memory.pyx", line 1116, in cupy.cuda.memory.SingleDeviceMemoryPool.malloc
File "cupy\cuda\memory.pyx", line 1137, in cupy.cuda.memory.SingleDeviceMemoryPool._malloc
File "cupy\cuda\memory.pyx", line 1382, in cupy.cuda.memory.SingleDeviceMemoryPool._try_malloc
File "cupy\cuda\memory.pyx", line 1385, in cupy.cuda.memory.SingleDeviceMemoryPool._try_malloc
cupy.cuda.memory.OutOfMemoryError: Out of memory allocating 41,483,834,880 bytes (allocated so far: 5,700,069,376 bytes).
2026-03-25 14:28:40,163 - INFO - An error occurred.##