help > importing existing connectivity matrices in CONN
Showing 1-14 of 14 posts
Display:
Results per page:
Jan 7, 2021  02:01 PM | Jaron Kupers
importing existing connectivity matrices in CONN
Hello,

We are new to CONN. We would like to use CONN for the visualization of already analyzed resting-state fMRI results. We have already processed  rs-fmri data, and constructed matrices of ROI connectivity and used in NBS. We are happy with the results, but not with the visualization tools offered in NBS. We were wondering therefore whether it Is possible to import only the connectivity matrices together with the mni labels and coordinates (in text files), hence without being forced to redo the preprocessing steps in CONN?

Thanks.

jaron
Jan 7, 2021  07:01 PM | Alfonso Nieto-Castanon - Boston University
RE: importing existing connectivity matrices in CONN
Hi Jaron,
Yes, that is perfectly fine, to run second-level analyses of arbitrary ROI-to-ROI connectivity matrices you may:

1) convert first your matrix data to NIFTI format, for example using something like:

   conn_mtx_write('/folder/mydatafile.mtx.nii', Z);

where Z is your ROI-by-ROI-by-subjects 3D matrix containing the connectivity values for each subject. You may also include the ROI labels as well as the ROI spatial locations info to the conn_mtx_write command if you wish, see "help conn_mtx_write" for additional details

2) run your desired group-level analyses, for example using something like:

   conn_module( 'glm' , ...
   'data', '/folder/mydatafile.mtx.nii', ...
   'design_matrix', X, ...
   'contrast_between', C, ...
   'contrast_within', M, ...
   'folder', '/folder/myresults' );

where X is your design matrix, and C/M are the between- and within- subjects contrast, respectively (see https://web.conn-toolbox.org/fmri-method... for details)

and 3) after that, you may display the second-level results using the standard CONN gui options at any time using the syntax:

  conn_display /folder/myresults

Hope this helps
Alfonso


Originally posted by Jaron Kupers:
Hello,

We are new to CONN. We would like to use CONN for the visualization of already analyzed resting-state fMRI results. We have already processed  rs-fmri data, and constructed matrices of ROI connectivity and used in NBS. We are happy with the results, but not with the visualization tools offered in NBS. We were wondering therefore whether it Is possible to import only the connectivity matrices together with the mni labels and coordinates (in text files), hence without being forced to redo the preprocessing steps in CONN?

Thanks.

jaron
Jan 8, 2021  09:01 AM | Jaron Kupers
RE: importing existing connectivity matrices in CONN
Dear Alfonso,

Thanks for your prompt response. We tried to to run the functions you mentioned. We managed to convert our matrix into NIFTI format using "conn_mtx_write". However, when we tried to run our group-level analysis using "conn_module", we got an error message that there is a mismatch in the number of subjects in the design matrix. CONN only finds 1 subject whereas our design matrix contains a total of 100 subjects (2 times 50 subjects for 2 different conditions). I attach the matrix and the error message.
Thanks in advance.

Jaron
Attachment: CONN_issue.zip
Jan 11, 2021  11:01 PM | Alfonso Nieto-Castanon - Boston University
RE: importing existing connectivity matrices in CONN
Sorry the zip file appears empty, could you please resend? (alternatively if its size is too large please send by email)
Originally posted by Jaron Kupers:
Dear Alfonso,

Thanks for your prompt response. We tried to to run the functions you mentioned. We managed to convert our matrix into NIFTI format using "conn_mtx_write". However, when we tried to run our group-level analysis using "conn_module", we got an error message that there is a mismatch in the number of subjects in the design matrix. CONN only finds 1 subject whereas our design matrix contains a total of 100 subjects (2 times 50 subjects for 2 different conditions). I attach the matrix and the error message.
Thanks in advance.

Jaron
Jan 14, 2021  01:01 PM | Jaron Kupers
RE: importing existing connectivity matrices in CONN
I sent the files to you by email. They were probably too large.

Jaron
Originally posted by Alfonso Nieto-Castanon:
Sorry the zip file appears empty, could you please resend? (alternatively if its size is too large please send by email)
Originally posted by Jaron Kupers:
Dear Alfonso,

Thanks for your prompt response. We tried to to run the functions you mentioned. We managed to convert our matrix into NIFTI format using "conn_mtx_write". However, when we tried to run our group-level analysis using "conn_module", we got an error message that there is a mismatch in the number of subjects in the design matrix. CONN only finds 1 subject whereas our design matrix contains a total of 100 subjects (2 times 50 subjects for 2 different conditions). I attach the matrix and the error message.
Thanks in advance.

Jaron
Jan 15, 2021  06:01 PM | Alfonso Nieto-Castanon - Boston University
RE: importing existing connectivity matrices in CONN
Dear Jaron,

The .mtx.nii file appears perfectly fine (except perhaps matrix #93 which appears to contain a lot of missing values), so using a design matrix with 50 rows and any arbitrary number of columns should have worked perfectly fine. Could you please double-check and/or share the form of the conn_module command that you used and in particular the choice of 'design_matrix' field entered?

Best
Alfonso
Originally posted by Jaron Kupers:
Dear Alfonso,

Thanks for your prompt response. We tried to to run the functions you mentioned. We managed to convert our matrix into NIFTI format using "conn_mtx_write". However, when we tried to run our group-level analysis using "conn_module", we got an error message that there is a mismatch in the number of subjects in the design matrix. CONN only finds 1 subject whereas our design matrix contains a total of 100 subjects (2 times 50 subjects for 2 different conditions). I attach the matrix and the error message.
Thanks in advance.

Jaron
Jan 21, 2021  12:01 PM | Jaron Kupers
RE: importing existing connectivity matrices in CONN
Dear Alfonso,

The conn-module command we used is the following:
conn_module( 'glm' , ...
'data', 'med100sujetsp.mtx.nii', ...
'design_matrix', X, ...
'contrast_between', C, ...
'folder', 'C:\Users\laurence\Documents\MATLAB\ ron\' );
We played a bit with the design and contrast matrices but to no avail. We still get the message that there is a mismatch in the number of subjects in the design matrix. I attach the design matrix and one of the contrasts we tried. The 50 first columns in the design matrix are for the rsfMRI data of session 1, the next 50 are related to the second rsfMRI condition (X). The first 50 lines in our data matrix (mtx.nii) refer to our 50 subjects in condition 1, the next 50 lines refer to the same subjects in condition 2. Our aim is to perform a paired t-test (50 subjects, tested in 2 conditions). We tried various possible contrasts but they all gave the same error message.
Attachment: design.xlsx
Jul 14, 2022  08:07 AM | Samantha Baldi
RE: importing existing connectivity matrices in CONN
Dear Alfonso, 

I had exactly the same needs so I implemented what you suggested in this post. 
This generated an SPM.mat file, together with a spmF_mv.nii, spmF_mv.json and mask.nii files. 
I am now trying to load the results with conn_display SPM.mat, however I get the following error: 

Loading /rds/user/sb2506/hpc-work/tFMRI_PPI/2ndlevel/dep/SPM.mat
please wait...
Error using regexprep
All cells must be char row vectors.

Error in conn_displayroi (line 204)
data.names=regexprep(data.names,{'_1_1$','^rs\.','^rsREL\.','^aal\.'},'');
Error in conn_display (line 209)
hfigure=conn_displayroi('initspm',fullfile(filepath,[filename,fileext]),varargin{:});

Any idea where this might come from?
Jul 19, 2022  09:07 PM | Alfonso Nieto-Castanon - Boston University
RE: importing existing connectivity matrices in CONN
Dear Samantha,

That seems to indicate some issue with the ROI labels defined in your matrix NIFTI files, could you check if when creating your nifti files you may have used some syntax like:
 
conn_mtx_write(filename, Z, ROIlabels);

If so make sure that the ROIlabels variable is a cell array containing one label per row/column of Z, e.g.

ROIlabels = {'ROI1', 'ROI2', 'ROI3'}; 

(alternatively look at the .json file associated with your matrix NIFTI files to see if that contains non-string elements in the "names" field?)

Hope this helps
Alfonso
Originally posted by Samantha Baldi:
Dear Alfonso, 

I had exactly the same needs so I implemented what you suggested in this post. 
This generated an SPM.mat file, together with a spmF_mv.nii, spmF_mv.json and mask.nii files. 
I am now trying to load the results with conn_display SPM.mat, however I get the following error: 

Loading /rds/user/sb2506/hpc-work/tFMRI_PPI/2ndlevel/dep/SPM.mat
please wait...
Error using regexprep
All cells must be char row vectors.

Error in conn_displayroi (line 204)
data.names=regexprep(data.names,{'_1_1$','^rs\.','^rsREL\.','^aal\.'},'');
Error in conn_display (line 209)
hfigure=conn_displayroi('initspm',fullfile(filepath,[filename,fileext]),varargin{:});

Any idea where this might come from?
Aug 22, 2022  08:08 AM | chirokoff
RE: importing existing connectivity matrices in CONN
Hello,
I am currently trying to import connectivity matrices analyzed via an other software as described in the following post. I managed to create the .mtx.nii but when I tried to run the conn_module using :
"conn_module( 'glm' , ...
'data', Files.mtx.nii, ...
'design_matrix', X, ...
'contrast_between', C, ...
'contrast_within', M, ...
'folder', folder);

"
I get the following error message :" Too many input argument".

Using :
"conn_module( 'glm' , ...
'Files.mtx.nii', ...
'X', ...
'C', ...
'M', ...
'folder')
"
Fix the bug but results in another error "Incorrect dimensions (X and C1 should have the same number of columns)" (X and C does have the same numbers of colums).

I managed to run the function anyway using :
"
conn_module_glm(X, Files.mtx.nii; C, M, folder)
"
But then i get :

"
Warning: Matrix is singular to working precision.
> In spm_inv (line 30)
In spm_reml (line 100)
In spm_est_non_sphericity (line 281)
In spm_spm (line 433)
In conn_module_glm (line 151)

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
-1.000000e+00.
> In spm_inv (line 30)
In spm_reml (line 103)
In spm_est_non_sphericity (line 281)
In spm_spm (line 433)
In conn_module_glm (line 151)
Error using spm_dx>expv (line 279)
The requested tolerance is too high.
Error in spm_dx (line 102)
dx = expv(1,J,x);
Error in spm_reml (line 145)
dh = spm_dx(dFdhh,dFdh,{t});
Error in spm_est_non_sphericity (line 281)
[V,h] = spm_reml(Cy,xX.X,xVi.Vi);
Error in spm_spm (line 433)
[xVi, am] = spm_est_non_sphericity(SPM);
Error in conn_module_glm (line 151)
SPM=spm_spm(SPM);
"
Does someone know how to fix this ?

Thank you a lot for your help,

Valentine


Originally posted by Alfonso Nieto-Castanon:
Hi Jaron,
Yes, that is perfectly fine, to run second-level analyses of arbitrary ROI-to-ROI connectivity matrices you may:

1) convert first your matrix data to NIFTI format, for example using something like:

   conn_mtx_write('/folder/mydatafile.mtx.nii', Z);

where Z is your ROI-by-ROI-by-subjects 3D matrix containing the connectivity values for each subject. You may also include the ROI labels as well as the ROI spatial locations info to the conn_mtx_write command if you wish, see "help conn_mtx_write" for additional details

2) run your desired group-level analyses, for example using something like:

   conn_module( 'glm' , ...
   'data', '/folder/mydatafile.mtx.nii', ...
   'design_matrix', X, ...
   'contrast_between', C, ...
   'contrast_within', M, ...
   'folder', '/folder/myresults' );

where X is your design matrix, and C/M are the between- and within- subjects contrast, respectively (see https://web.conn-toolbox.org/fmri-method... for details)

and 3) after that, you may display the second-level results using the standard CONN gui options at any time using the syntax:

  conn_display /folder/myresults

Hope this helps
Alfonso


Originally posted by Jaron Kupers:
Hello,

We are new to CONN. We would like to use CONN for the visualization of already analyzed resting-state fMRI results. We have already processed  rs-fmri data, and constructed matrices of ROI connectivity and used in NBS. We are happy with the results, but not with the visualization tools offered in NBS. We were wondering therefore whether it Is possible to import only the connectivity matrices together with the mni labels and coordinates (in text files), hence without being forced to redo the preprocessing steps in CONN?

Thanks.

jaron
Aug 29, 2022  05:08 PM | Alfonso Nieto-Castanon - Boston University
RE: importing existing connectivity matrices in CONN

Hi

I would probably suggest trying entering your options in a .cfg file instead of from the command-line, see for example the documentation and example in https://web.conn-toolbox.org/resources/e...

Best
Alfonso

Originally posted by chirokoff:
Hello,
I am currently trying to import connectivity matrices analyzed via an other software as described in the following post. I managed to create the .mtx.nii but when I tried to run the conn_module using :
"conn_module( 'glm' , ...
'data', Files.mtx.nii, ...
'design_matrix', X, ...
'contrast_between', C, ...
'contrast_within', M, ...
'folder', folder);

"
I get the following error message :" Too many input argument".

Using :
"conn_module( 'glm' , ...
'Files.mtx.nii', ...
'X', ...
'C', ...
'M', ...
'folder')
"
Fix the bug but results in another error "Incorrect dimensions (X and C1 should have the same number of columns)" (X and C does have the same numbers of colums).

I managed to run the function anyway using :
"
conn_module_glm(X, Files.mtx.nii; C, M, folder)
"
But then i get :

"
Warning: Matrix is singular to working precision.
> In spm_inv (line 30)
In spm_reml (line 100)
In spm_est_non_sphericity (line 281)
In spm_spm (line 433)
In conn_module_glm (line 151)

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
-1.000000e+00.
> In spm_inv (line 30)
In spm_reml (line 103)
In spm_est_non_sphericity (line 281)
In spm_spm (line 433)
In conn_module_glm (line 151)
Error using spm_dx>expv (line 279)
The requested tolerance is too high.
Error in spm_dx (line 102)
dx = expv(1,J,x);
Error in spm_reml (line 145)
dh = spm_dx(dFdhh,dFdh,{t});
Error in spm_est_non_sphericity (line 281)
[V,h] = spm_reml(Cy,xX.X,xVi.Vi);
Error in spm_spm (line 433)
[xVi, am] = spm_est_non_sphericity(SPM);
Error in conn_module_glm (line 151)
SPM=spm_spm(SPM);
"
Does someone know how to fix this ?

Thank you a lot for your help,

Valentine


Originally posted by Alfonso Nieto-Castanon:
Hi Jaron,
Yes, that is perfectly fine, to run second-level analyses of arbitrary ROI-to-ROI connectivity matrices you may:

1) convert first your matrix data to NIFTI format, for example using something like:

   conn_mtx_write('/folder/mydatafile.mtx.nii', Z);

where Z is your ROI-by-ROI-by-subjects 3D matrix containing the connectivity values for each subject. You may also include the ROI labels as well as the ROI spatial locations info to the conn_mtx_write command if you wish, see "help conn_mtx_write" for additional details

2) run your desired group-level analyses, for example using something like:

   conn_module( 'glm' , ...
   'data', '/folder/mydatafile.mtx.nii', ...
   'design_matrix', X, ...
   'contrast_between', C, ...
   'contrast_within', M, ...
   'folder', '/folder/myresults' );

where X is your design matrix, and C/M are the between- and within- subjects contrast, respectively (see https://web.conn-toolbox.org/fmri-method... for details)

and 3) after that, you may display the second-level results using the standard CONN gui options at any time using the syntax:

  conn_display /folder/myresults

Hope this helps
Alfonso


Originally posted by Jaron Kupers:
Hello,

We are new to CONN. We would like to use CONN for the visualization of already analyzed resting-state fMRI results. We have already processed  rs-fmri data, and constructed matrices of ROI connectivity and used in NBS. We are happy with the results, but not with the visualization tools offered in NBS. We were wondering therefore whether it Is possible to import only the connectivity matrices together with the mni labels and coordinates (in text files), hence without being forced to redo the preprocessing steps in CONN?

Thanks.

jaron
Aug 31, 2022  10:08 AM | chirokoff
RE: importing existing connectivity matrices in CONN
Dear Alfonso,
Thank you for your response. I tried entering my options as suggested but I get the following error message :

"
conn module glm /data/valentine/DicLearning/ConnToolbox/ConfFiles.cfg
ERROR DESCRIPTION:

Not enough input arguments.

Error in conn_module_glm (line 31)
if ischar(filenames), filenames=cellstr(filenames); end
Error in conn_module (line 325)
else feval(fh,varargin{:});
Error in conn (line 9636)
if ~nargout, feval(fh,varargin{2:end})
"

My configuration files contains the following informations :

"
#data
/data/Matcorrelation1.mtx.nii
/data/Matcorrelation2.mtx.nii
/data/Matcorrelation3.mtx.nii
/data/Matcorrelation4.mtx.nii
/data/Matcorrelation5.mtx.nii
/data/Matcorrelation6.mtx.nii
/data/Matcorrelation7.mtx.nii
/data/Matcorrelation8.mtx.nii
/data/Matcorrelation9.mtx.nii
/data/Matcorrelation10.mtx.nii
/data/Matcorrelation11.mtx.nii
/data/Matcorrelation12.mtx.nii
/data/Matcorrelation13.mtx.nii
/data/Matcorrelation14.mtx.nii
/data/Matcorrelation15.mtx.nii
/data/Matcorrelation16.mtx.nii
/data/Matcorrelation17.mtx.nii
/data/Matcorrelation18.mtx.nii
/data/Matcorrelation19.mtx.nii
/data/Matcorrelation20.mtx.nii
/data/Matcorrelation21.mtx.nii
/data/Matcorrelation22.mtx.nii
/data/Matcorrelation23.mtx.nii
/data/Matcorrelation24.mtx.nii
/data/Matcorrelation25.mtx.nii
/data/Matcorrelation26.mtx.nii
/data/Matcorrelation27.mtx.nii
/data/Matcorrelation28.mtx.nii
/data/Matcorrelation29.mtx.nii
/data/Matcorrelation30.mtx.nii
/data/Matcorrelation31.mtx.nii
/data/Matcorrelation32.mtx.nii
/data/Matcorrelation33.mtx.nii
/data/Matcorrelation34.mtx.nii
/data/Matcorrelation35.mtx.nii
/data/Matcorrelation36.mtx.nii
/data/Matcorrelation37.mtx.nii
/data/Matcorrelation38.mtx.nii
/data/Matcorrelation39.mtx.nii
/data/Matcorrelation40.mtx.nii

#design
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
10216.0909090909 16424.8750000000 14421 14064.0909090909 14474.2500000000 14677.3000000000 15574.5454545455 9900 19186.4166666667 8704.70000000000 15216.9166666667 9029.30769230769 8771.18181818182 18489.2500000000 17503.7692307692 9658.81818181818 9141.33333333333 9136.16666666667 24469.4000000000 11631 10169.2222222222 15095.5714285714 13452.0909090909 16820.6923076923 15999.5454545455 14649.4444444444 17008.6363636364 12680.3076923077 17211.2307692308 10661.2307692308 14627.4545454545 13310.1538461538 13099.6923076923 11844.1818181818 18468.5384615385 17644.5384615385 32163.2500000000 14139.2500000000 7381.30769230769 9183.76923076923
33 52 45 55 54 41 31 42 52 34 53 46 35 27 53 35 19 22 61 37 28 34 38 41 52 35 31 62 55 55 45 45 56 52 42 62 35 34 27 41
#contrast_between
0 1 0
#folder
/home/Results/
"

Do you know what could be wrong ?

Thank you for your help,

Valentine

Originally posted by Alfonso Nieto-Castanon:

Hi

I would probably suggest trying entering your options in a .cfg file instead of from the command-line, see for example the documentation and example in https://web.conn-toolbox.org/resources/e...

Best
Alfonso

Originally posted by chirokoff:
Hello,
I am currently trying to import connectivity matrices analyzed via an other software as described in the following post. I managed to create the .mtx.nii but when I tried to run the conn_module using :
"conn_module( 'glm' , ...
'data', Files.mtx.nii, ...
'design_matrix', X, ...
'contrast_between', C, ...
'contrast_within', M, ...
'folder', folder);

"
I get the following error message :" Too many input argument".

Using :
"conn_module( 'glm' , ...
'Files.mtx.nii', ...
'X', ...
'C', ...
'M', ...
'folder')
"
Fix the bug but results in another error "Incorrect dimensions (X and C1 should have the same number of columns)" (X and C does have the same numbers of colums).

I managed to run the function anyway using :
"
conn_module_glm(X, Files.mtx.nii; C, M, folder)
"
But then i get :

"
Warning: Matrix is singular to working precision.
> In spm_inv (line 30)
In spm_reml (line 100)
In spm_est_non_sphericity (line 281)
In spm_spm (line 433)
In conn_module_glm (line 151)

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
-1.000000e+00.
> In spm_inv (line 30)
In spm_reml (line 103)
In spm_est_non_sphericity (line 281)
In spm_spm (line 433)
In conn_module_glm (line 151)
Error using spm_dx>expv (line 279)
The requested tolerance is too high.
Error in spm_dx (line 102)
dx = expv(1,J,x);
Error in spm_reml (line 145)
dh = spm_dx(dFdhh,dFdh,{t});
Error in spm_est_non_sphericity (line 281)
[V,h] = spm_reml(Cy,xX.X,xVi.Vi);
Error in spm_spm (line 433)
[xVi, am] = spm_est_non_sphericity(SPM);
Error in conn_module_glm (line 151)
SPM=spm_spm(SPM);
"
Does someone know how to fix this ?

Thank you a lot for your help,

Valentine


Originally posted by Alfonso Nieto-Castanon:
Hi Jaron,
Yes, that is perfectly fine, to run second-level analyses of arbitrary ROI-to-ROI connectivity matrices you may:

1) convert first your matrix data to NIFTI format, for example using something like:

   conn_mtx_write('/folder/mydatafile.mtx.nii', Z);

where Z is your ROI-by-ROI-by-subjects 3D matrix containing the connectivity values for each subject. You may also include the ROI labels as well as the ROI spatial locations info to the conn_mtx_write command if you wish, see "help conn_mtx_write" for additional details

2) run your desired group-level analyses, for example using something like:

   conn_module( 'glm' , ...
   'data', '/folder/mydatafile.mtx.nii', ...
   'design_matrix', X, ...
   'contrast_between', C, ...
   'contrast_within', M, ...
   'folder', '/folder/myresults' );

where X is your design matrix, and C/M are the between- and within- subjects contrast, respectively (see https://web.conn-toolbox.org/fmri-method... for details)

and 3) after that, you may display the second-level results using the standard CONN gui options at any time using the syntax:

  conn_display /folder/myresults

Hope this helps
Alfonso


Originally posted by Jaron Kupers:
Hello,

We are new to CONN. We would like to use CONN for the visualization of already analyzed resting-state fMRI results. We have already processed  rs-fmri data, and constructed matrices of ROI connectivity and used in NBS. We are happy with the results, but not with the visualization tools offered in NBS. We were wondering therefore whether it Is possible to import only the connectivity matrices together with the mni labels and coordinates (in text files), hence without being forced to redo the preprocessing steps in CONN?

Thanks.

jaron
Aug 31, 2022  10:08 AM | Alfonso Nieto-Castanon - Boston University
RE: importing existing connectivity matrices in CONN
Dear Valentine,

Seems like an installation issue, please double-check that you have the latest CONN/SPM software installed and then type in Matlab's command-line the following:

   pathtool

and in the resulting GUI remove any entries in your path that may contain older versions of CONN (the list of path entries should look like the example in https://web.conn-toolbox.org/resources/i...). 

To double-check that everything seems fine you may type in Matlab's command-line the following:

   which conn_module_glm

and that should produce a message of the form:

'conn_module_glm' not found.

Hope this helps
Alfonso
Originally posted by chirokoff:
Dear Alfonso,
Thank you for your response. I tried entering my options as suggested but I get the following error message :

"
conn module glm /data/valentine/DicLearning/ConnToolbox/ConfFiles.cfg
ERROR DESCRIPTION:

Not enough input arguments.

Error in conn_module_glm (line 31)
if ischar(filenames), filenames=cellstr(filenames); end
Error in conn_module (line 325)
else feval(fh,varargin{:});
Error in conn (line 9636)
if ~nargout, feval(fh,varargin{2:end})
"

My configuration files contains the following informations :

"
#data
/data/Matcorrelation1.mtx.nii
/data/Matcorrelation2.mtx.nii
/data/Matcorrelation3.mtx.nii
/data/Matcorrelation4.mtx.nii
/data/Matcorrelation5.mtx.nii
/data/Matcorrelation6.mtx.nii
/data/Matcorrelation7.mtx.nii
/data/Matcorrelation8.mtx.nii
/data/Matcorrelation9.mtx.nii
/data/Matcorrelation10.mtx.nii
/data/Matcorrelation11.mtx.nii
/data/Matcorrelation12.mtx.nii
/data/Matcorrelation13.mtx.nii
/data/Matcorrelation14.mtx.nii
/data/Matcorrelation15.mtx.nii
/data/Matcorrelation16.mtx.nii
/data/Matcorrelation17.mtx.nii
/data/Matcorrelation18.mtx.nii
/data/Matcorrelation19.mtx.nii
/data/Matcorrelation20.mtx.nii
/data/Matcorrelation21.mtx.nii
/data/Matcorrelation22.mtx.nii
/data/Matcorrelation23.mtx.nii
/data/Matcorrelation24.mtx.nii
/data/Matcorrelation25.mtx.nii
/data/Matcorrelation26.mtx.nii
/data/Matcorrelation27.mtx.nii
/data/Matcorrelation28.mtx.nii
/data/Matcorrelation29.mtx.nii
/data/Matcorrelation30.mtx.nii
/data/Matcorrelation31.mtx.nii
/data/Matcorrelation32.mtx.nii
/data/Matcorrelation33.mtx.nii
/data/Matcorrelation34.mtx.nii
/data/Matcorrelation35.mtx.nii
/data/Matcorrelation36.mtx.nii
/data/Matcorrelation37.mtx.nii
/data/Matcorrelation38.mtx.nii
/data/Matcorrelation39.mtx.nii
/data/Matcorrelation40.mtx.nii

#design
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
10216.0909090909 16424.8750000000 14421 14064.0909090909 14474.2500000000 14677.3000000000 15574.5454545455 9900 19186.4166666667 8704.70000000000 15216.9166666667 9029.30769230769 8771.18181818182 18489.2500000000 17503.7692307692 9658.81818181818 9141.33333333333 9136.16666666667 24469.4000000000 11631 10169.2222222222 15095.5714285714 13452.0909090909 16820.6923076923 15999.5454545455 14649.4444444444 17008.6363636364 12680.3076923077 17211.2307692308 10661.2307692308 14627.4545454545 13310.1538461538 13099.6923076923 11844.1818181818 18468.5384615385 17644.5384615385 32163.2500000000 14139.2500000000 7381.30769230769 9183.76923076923
33 52 45 55 54 41 31 42 52 34 53 46 35 27 53 35 19 22 61 37 28 34 38 41 52 35 31 62 55 55 45 45 56 52 42 62 35 34 27 41
#contrast_between
0 1 0
#folder
/home/Results/
"

Do you know what could be wrong ?

Thank you for your help,

Valentine

Originally posted by Alfonso Nieto-Castanon:

Hi

I would probably suggest trying entering your options in a .cfg file instead of from the command-line, see for example the documentation and example in https://web.conn-toolbox.org/resources/e...

Best
Alfonso

Originally posted by chirokoff:
Hello,
I am currently trying to import connectivity matrices analyzed via an other software as described in the following post. I managed to create the .mtx.nii but when I tried to run the conn_module using :
"conn_module( 'glm' , ...
'data', Files.mtx.nii, ...
'design_matrix', X, ...
'contrast_between', C, ...
'contrast_within', M, ...
'folder', folder);

"
I get the following error message :" Too many input argument".

Using :
"conn_module( 'glm' , ...
'Files.mtx.nii', ...
'X', ...
'C', ...
'M', ...
'folder')
"
Fix the bug but results in another error "Incorrect dimensions (X and C1 should have the same number of columns)" (X and C does have the same numbers of colums).

I managed to run the function anyway using :
"
conn_module_glm(X, Files.mtx.nii; C, M, folder)
"
But then i get :

"
Warning: Matrix is singular to working precision.
> In spm_inv (line 30)
In spm_reml (line 100)
In spm_est_non_sphericity (line 281)
In spm_spm (line 433)
In conn_module_glm (line 151)

Warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND =
-1.000000e+00.
> In spm_inv (line 30)
In spm_reml (line 103)
In spm_est_non_sphericity (line 281)
In spm_spm (line 433)
In conn_module_glm (line 151)
Error using spm_dx>expv (line 279)
The requested tolerance is too high.
Error in spm_dx (line 102)
dx = expv(1,J,x);
Error in spm_reml (line 145)
dh = spm_dx(dFdhh,dFdh,{t});
Error in spm_est_non_sphericity (line 281)
[V,h] = spm_reml(Cy,xX.X,xVi.Vi);
Error in spm_spm (line 433)
[xVi, am] = spm_est_non_sphericity(SPM);
Error in conn_module_glm (line 151)
SPM=spm_spm(SPM);
"
Does someone know how to fix this ?

Thank you a lot for your help,

Valentine


Originally posted by Alfonso Nieto-Castanon:
Hi Jaron,
Yes, that is perfectly fine, to run second-level analyses of arbitrary ROI-to-ROI connectivity matrices you may:

1) convert first your matrix data to NIFTI format, for example using something like:

   conn_mtx_write('/folder/mydatafile.mtx.nii', Z);

where Z is your ROI-by-ROI-by-subjects 3D matrix containing the connectivity values for each subject. You may also include the ROI labels as well as the ROI spatial locations info to the conn_mtx_write command if you wish, see "help conn_mtx_write" for additional details

2) run your desired group-level analyses, for example using something like:

   conn_module( 'glm' , ...
   'data', '/folder/mydatafile.mtx.nii', ...
   'design_matrix', X, ...
   'contrast_between', C, ...
   'contrast_within', M, ...
   'folder', '/folder/myresults' );

where X is your design matrix, and C/M are the between- and within- subjects contrast, respectively (see https://web.conn-toolbox.org/fmri-method... for details)

and 3) after that, you may display the second-level results using the standard CONN gui options at any time using the syntax:

  conn_display /folder/myresults

Hope this helps
Alfonso


Originally posted by Jaron Kupers:
Hello,

We are new to CONN. We would like to use CONN for the visualization of already analyzed resting-state fMRI results. We have already processed  rs-fmri data, and constructed matrices of ROI connectivity and used in NBS. We are happy with the results, but not with the visualization tools offered in NBS. We were wondering therefore whether it Is possible to import only the connectivity matrices together with the mni labels and coordinates (in text files), hence without being forced to redo the preprocessing steps in CONN?

Thanks.

jaron
Mar 25, 2026  03:03 PM | tbn
RE: importing existing connectivity matrices in CONN

Hi everyone,


I’m trying to run second-level analyses in CONN, but I’ve run into some confusion and would really appreciate some guidance.


I’ve already completed my first-level analyses using the TMFC toolbox. This gave me ROI-to-ROI connectivity matrices (not z-scores, but subject-level beta/contrast estimates) for different task conditions. So for each subject and condition, I have a full connectivity matrix (ROI × ROI).


My goal is to take these matrices and perform second-level analyses in CONN, specifically:




  • Seed-based ROI-to-ROI analysis using the NAcc as seed (left and right separately)




  • Group comparisons 




  • Regressions with clinical variables




  • Across multiple condition contrasts (e.g., condition A > condition B,  etc.)




I tried to integrate these outputs into CONN by using a script with functions like conn_mtx_write to format my matrices into .mtx.nii files, assuming this might allow CONN to treat them as first-level inputs for second-level analysis.


However, I’m not fully sure how to correctly define and use the NAcc (left and right) as seeds in this setup. Is there a code template or similar?


I would really appreciate any advice or examples of how to properly set this up.


Thanks a lot in advance!