help > RE: Changing data's location
Feb 15, 2016  04:02 PM | Jalmar Teeuw
RE: Changing data's location
You could try a 'search & replace' on the CONN_x structure stored in the project file. For example: http://nl.mathworks.com/matlabcentral/fileexchange/27858-struct-string-replace

I didn't Google when we ran into the same issue, so instead of using an existing Matlab package I wrote a small Matlab function that performs the same (see files in attached zip file). If you perform a search & replace, be sure to add SPM and CONN to Matlab's PATH, otherwise you might get warnings about Matlab not understanding 'nifti' structures when loading the project file and it may not traverse these structures during the find & replace.

In case you want to the scripts attached, you would run

  find_and_replace_matfile(source_filename, target_filename, needle, replace)

Where source_filename is the path to the CONN conn_*.mat project file you which to alter,
The target_filename is the path where you would like to save the modified version of the CONN project file (best to use a different target filename than the source so you can check if the search & replace works before you remove to original CONN project file)
The needle is what you want to search for, in this case the path where the CONN project file was store (usually it contains the conn_*.mat project file and folder); e.g. the string '/mnt/data/HPC-cluster/temp/username/projects/conn-subject-001' 
The replace is what you want the needle to be replaced with, in this case the location where the project is currently stored; e.g. the string '/Users/username/Projects/conn-subject-001'

In addition to find & replace the root of the project folder, we also had to replace the path to the atlas ROI used in CONN. I.e. replace something like '/mnt/home/username/Matlab/CONN/' with '/Users/username/Matlab/CONN/'. You just repeat the find & replace until CONN is satisfied it found all the files.

Attached is a quick & dirty recursive search & replace function, but it works for our project files. However, it may not work on every project, so maybe better to use on of the existing (and more thoroughly tested) packages from Matlab Central. Nevertheless, the idea is the same.

Cheers,
Jalmar

Threaded View

TitleAuthorDate
Bob Kraft Feb 15, 2016
Benson Stevens Mar 21, 2019
Alfonso Nieto-Castanon Feb 17, 2016
RE: Changing data's location
Jalmar Teeuw Feb 15, 2016
Bob Kraft Feb 17, 2016