Freesurfer autorecon2 mri_normalize "Cannot allocate memory" Error

Summary of what happened:

Hi there,

I’ve successfully run recon-all on over 100 subjects from the same dataset, but for whatever reason, for one single subject, it fails everytime at the autorecon2 mri_normalize command. I’m pasting this portion of the log file below (won’t let me attach the file for some reason).

I’ve tried increasing the memory (to far more than should be needed) multiple times to no avail. I’ve also visually inspected brainmask.mgz, norm.mgz, and aseg.presurf.mgz in freeview and nothing appears problematic or out of the ordinary.

I’m new to freesurfer, so any help troubleshooting this would be greatly appreciated!

Thanks in advance,

Cameron

Command used (and if a helper script was used, a link to the helper script or the command generated):

PASTE CODE HERE

Version:

Freesurfer version: freesurfer-linux-rocky8_x86_64-8.1.0-20250718-f30dfed

Environment (Docker, Singularity / Apptainer, custom installation):

uname -a: Linux li04e03 5.14.0-570.58.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Oct 31 13:55:05 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux

Platform: Rocky Linux 9.8 (Blue Onyx), x86_64

Data formatted according to a validatable standard? Please provide the output of the validator:

PASTE VALIDATOR OUTPUT HERE

Relevant log outputs (up to 20 lines):

#@# Intensity Normalization2 Wed Jul 15 15:41:44 EDT 2026/sc/arion/projects/guLab/BPD/derivatives/freesurfer/sub-5034/mri

mri_normalize -seed 1234 -mprage -noconform -aseg aseg.presurf.mgz -mask brainmask.mgz norm.mgz brain.mgz

setting seed for random number genererator to 1234assuming input volume is MGH (Van der Kouwe) MP-RAGEnot interpolating and embedding volume to be 256^3…using segmentation for initial intensity normalizationusing MR volume brainmask.mgz to mask input volume…reading mri_src from norm.mgz…Reading aseg aseg.presurf.mgzaseg read with width 320 (src width 320)normalizing image…NOT doing gentle normalization with control points/labelprocessing with asegremoving outliers in the aseg WM…4148 control points removedBuilding bias imagebuilding Voronoi diagram…performing soap bubble smoothing, sigma = 0…Smoothing with sigma 8Applying bias correctionbuilding Voronoi diagram…performing soap bubble smoothing, sigma = 8…

Iterating 2 times

3d normalization pass 1 of 2white matter peak found at 110error: Cannot allocate memoryerror: HISTOalloc(-2147483648): could not allocate histogramCommand exited with non-zero status 254@#@FSTIMEFSTIMEFSTIMEFSTIME  2026:07:15:15:41:44 mri_normalize N 10 e 172.00 S 1.32 U 170.04 P 99% M 2275988 F 0 R 405362 W 0 c 1961 w 6 I 0 O 0 L 9.70 8.74 10@FSLOADPOST37@#@FSLOADPOST 2026:07:15:15:44:36 mri_normalize N 10 9.32 8.84 10.11Linux lh06c24 5.14.0-687.12.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Fri May 29 11:50:59 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux

recon-all -s sub-5034 exited with ERRORS at Wed Jul 15 15:44:36 EDT 2026

Screenshots / relevant information:


One thing that stands out to me is the HISTOalloc(-2147483648) value. Since it’s only happening for one subject, I’d wonder if there’s something unusual about that specific input rather than the available RAM. Have you compared that subject’s norm.mgz, brainmask.mgz, and aseg.presurf.mgz dimensions, voxel sizes, and header information against one of the subjects that completed successfully (e.g., using mri_info)? It might also be worth checking whether any of those files are corrupted or have unexpected header values.

Hi James,

Thank you for your response. I compared norm.mgz, brainmask.mgz, and aseg.presurf.mgz between this subject and a few others in the dataset using mri_info. The only thing that seems to differ is the center coordinates, as I would expect. Again, nothing out of the ordinary. I also visually compared them with freeview and nothing sticks out - intensity normalization, skull stripping, and segmentation all look relatively good/accurate and similar to other subjects. It’s possible that I’m missing something - it won’t let me upload the files so I’m pasting a screenshot of the segmentation overlaid on norm.mgz below: