ERROR (nifti_image_read): failed to find header file for 'insula_FC_R1/insula_mask_resampled.nii

Hi all,

I’m new to AFNI, and have toiled many hours debugging code that I don’t understand. Any help would be appreciated :slight_smile:
I’m trying to do a functional connectivity analysis, and I have a .nii file that is my mask for my ROI. I had to resample it using the 3dresample command so it would match the size of my scans. I call that new file insula_mask_resampled_nii. I have checked and that file is indeed written where I expected it to be. The next thing I try to do is average using 3dmaskav, and that line throws the error:
3dresample -master ${runs_dir}/*mefc.nii -prefix insula_mask_resampled.nii -input $roi
3dmaskave -mask $newROI -quiet ${run} > ${runnum}_${prefix}.1D

The error I get is ERROR (nifti_image_read): failed to find header file for 'insula_FC_R1/insula_mask_resampled.nii

Can anyone enlighten me as to what is happening?
Many thanks


It looks like you are likely just having trouble with the
directories that files are in.

The 3dresample command takes as input at dataset under
$runs_dir, however the -prefix option does not have any
directory. That means it should be place in the directory
where 3dresample was run from. Which directory is that?

If you do not change after that, as those commands suggest,
then newROI should not have any directory prefix.

But for any dataset and variable, first make sure that you
can see it with an ‘ls’ command, to verify it is where you
expect it to be.

For example, if just before the 3dmaskave command you were
to run “ls $newROI”, I expect it would show “No such file
or directory”.

  • rick

Thank you, I think you’re right and it must be a directories problem. I’m still struggling to fix it. After 3dresample, I’ve tried the following to located the insula_mask_resampled.nii file:

ls newROI

When the first ls prints the names of 3 files, one of which is insula_mask_resampled.nii. So it seems to be ing the working directory. I can even locate it in my file system and confirm that it is indeed at the path specified by pwd. However, when I set newROI to it, and ls newROI, I get the message no such file or directory. Even when I specify the entire path length printed in pwd, ls newROI has no file or directory. I know this isn’t an AFNI thing anymore, but any ideas?

Thank you.

You are just missing the ‘$’ to access a variable,
as $newROI rather than just newROI.

  • rick

Thank you a lot!