help > CONN25.b preprocessing error during direct coregistration after removing initial scans
4 hours ago | Ramesh Babu MG
CONN25.b preprocessing error during direct coregistration after removing initial scans

Dear Expert,


I am performing resting-state fMRI analysis for 108 subjects using CONN 25.b, SPM25 (25.01.02), and MATLAB R2023a Update 8 on Ubuntu 22.04.5 LTS.


The rsfMRI data were acquired on a Philips Achieva 1.5 T scanner using a Gradient Echo EPI sequence with the following parameters:


* Voxel size: 3 × 3 × 4 mm³
* Matrix: 64 × 64 × 34
* TR: 2.5 s
* Volumes: 200


I selected the Default MNI preprocessing pipeline and enabled "Remove first 5 scans". CONN consistently stops during Preparing functional → Direct coregistration to structural with the following error:


```
ERROR DESCRIPTION:


Error using conn_fileutils


Error copying file


.../subj003/rsfmri/aursfmri.nii,6


to


.../subj003/rsfmri/raursfmri.nii,6


missing file or invalid file permissions
```


The error originates from conn_setup_preproc.m, line 3037:


```matlab
conn_fileutils('filecopy', temp, newtemp);
```


To investigate, I manually tested the same subject using SPM25. Both Coregister: Estimate & Reslice and direct reading of the functional volumes completed successfully:


```matlab
V = spm_vol('aursfmri.nii');
length(V)
```


Output:


```matlab
200
```


```matlab
Y = spm_read_vols(V(6));
```


SPM successfully reads `aursfmri.nii,6`, indicating that the image and volume specification are valid.


I also inspected the CONN source code. In `conn_setup_preproc.m`, the filename is obtained using `conn_get_functional(...)` and passed to:


```matlab
conn_fileutils('filecopy', temp, newtemp);
```


In `conn_fileutils.m`, the copy operation is performed using the Linux `cp` command. Since `temp` contains an SPM volume specification such as:


```
aursfmri.nii,6
```


it appears that CONN passes this directly to `cp`, which interprets it as a filename rather than as "volume 6 of aursfmri.nii".


As a workaround, I removed the first five volumes before importing the data into CONN using FSL:


```bash
fslroi rsfmri.nii.gz rsfmri_trimmed.nii.gz 5 195
```


I then set "Remove first scans = 0" in CONN, and the preprocessing completed successfully for all tested subjects.


My question is: could this be a bug in CONN's preprocessing workflow, where `conn_fileutils('filecopy',...)` attempts to copy an SPM volume specification (e.g., `aursfmri.nii,6`) using the operating system `cp` command instead of first stripping the volume index from the filename? Alternatively, is there a recommended configuration or workaround for using the "Remove first scans" option with CONN 25.b and SPM25?


Thank you very much for your time and assistance.


Kind regards,


Ramesh Babu