OSCR

Enhanced sensorimotor cortex responsiveness to nonplegic hand stimulation and motor network assembly during recovery after spinal cord injury in primates.

Code ↔ Paper

3 matches between paragraphs of the paper and lines of its authors' code, computed by the harvester (lexical-v1). Click a colored paragraph or line to see its counterpart.

The 3 matches
  1. [1] § Methods › Statistical analysis ↔ python/fastECM/fastECM.py, lines 20–146 · score 0.66 · Fast eigenvector centrality, fMRI, node, connected, matrix, mapping
  2. [2] § Methods › Statistical analysis ↔ matlab/fastECM/fastECM.m, lines 1–71 · score 0.64 · Fast eigenvector centrality, fMRI, node, connected, matrix, mapping
  3. [3] § Methods › Statistical analysis ↔ matlab/fastECM/fastECM.m, lines 1–71 · score 0.55 · functional connectivity, Eigenvector centrality, ranks, brain, map

Paper

Loaded from Europe PMC by your browser, not stored by OSCR: doi.org · Europe PMC

The paper is loaded when this pane is shown.

The authors' code

MATLAB · 809 lines · 26 KB · GPL-3.0 · 2 matches

  1. function err = fastECM ( inputfile, rankmap, normmap, degmap, maxiter, maskfile, atlasfile, wholemat, dynamics, correlate )
  2. %
  3. % function fastECM ( string <inputfile>,
  4. % bool <rankmap>, bool <normmap>, bool <degmap>,
  5. % int maxiter,
  6. % string <maskfile>, string <atlasfile>,
  7. % bool wholemat,
  8. % int dynamics )
  9. % where - inputfile is the name of a 4D fMRI
  10. % image time series in the NifTI format
  11. % - rankmap ~= 0 produces a file rankECM.nii
  12. % with uniformly distributed [0, 1] centrality (tied) ranks
  13. % - normmap ~= 0 produces a file normECM.nii
  14. % with normally distributed N (0, 1) centralities generated from ranks
  15. % - degmap ~= 0 produces a node power map (similar to degree)
  16. % this is the column sum of connection strengths
  17. % - maxiter limits the number of iterations of the algorithm
  18. % - maskfile selects voxels inside a mask
  19. % - atlasfile groups signals by pre-defined regions
  20. % - wholemat: do not use the 'fast' recipe, write out
  21. % connectivity matrix and compute graph measures (costly!)
  22. % - dynamics: number of ECM to extract from a 4D fMRI
  23. % - correlate: way to approximate the eigenvector of
  24. % correlated time series:
  25. % 'fast' -- default, correlation + 1
  26. % 'relu' -- ReLU, rectified linear unit
  27. %
  28. % returns a file fastECM.nii in the same directory as <inputfile>
  29. % which contains a 'fast eigenvector centrality mapping'
  30. % whole-brain voxelwise functional connectivity analysis;
  31. % error code 0 if all is well, 1 otherwise
  32. %
  33. %
  34. %
  35. % Example 1
  36. %
  37. % If the following files are present:
  38. % fmri4d.nii.gz -- containing an fMRI time series
  39. % mask_csf.nii.gz -- mask with non-brain tissue and CSF removed
  40. % aal_MNI_V4_4mm_gong.nii.gz -- containing a volume with atlas labels
  41. % the call
  42. % >> fastECM;
  43. % runs a demo analysis highlighting all these options
  44. %
  45. % Example 2
  46. %
  47. % For using some, but not all options, the easiest way to
  48. % call fastECM is to pass these options in a struct:
  49. % >> op.inputfile = 'fmri4d.nii.gz';
  50. % >> op.dynamics = 25;
  51. % >> fastECM (op);
  52. %
  53. %
  54. %
  55. % (c) Alle Meije Wink -- 16/03/2012
  56. % a.m.wink AT gmail.com
  57. %
  58. %
  59. %
  60. % If you use this method in your research, remember to cite this paper
  61. % in the journal "Brain Connectivity":
  62. %
  63. % Alle Meije Wink, Jan C de Munck, Ysbrand D van der Werf, Odile A van den heuvel, Frederik Barkhof
  64. % "Fast eigenvector centrality mapping of voxel-wise connectivity in functional MRI:
  65. % implementation, validation and interpretation."
  66. % Brain Connectivity 2012, Vol. 2 No. 5, pages 265-274
  67. % URL: http://online.liebertpub.com/doi/abs/10.1089/brain.2012.0087
  68. % or: http://dare.ubvu.vu.nl/handle/1871/48750
  69. %
  70. %
  71. %
  72. % If called w/o agruments, produce a demo call
  73. if (~nargin)
  74. inputfile = [fileparts(which('fastECM.m')) filesep 'fmri4d.nii.gz' ];
  75. maskfile = [fileparts(which('fastECM.m')) filesep 'mask_csf.nii.gz' ];
  76. atlasfile = [fileparts(which('fastECM.m')) filesep 'aal_MNI_V4_4mm_gong.nii.gz' ];
  77. fprintf (2, ...
  78. ['\n syntax:\n fastECM (\n \t<str inputfile>, \n \t<bool rankmap>, <bool normmap>, ' ...
  79. '<bool degmap>, \n \t<int maxiter>, \n \t<str maskfile>, <str atlasfile>,' ...
  80. '\n \t<bool wholemat>,\n \t<int dynamics>,\n \t<str correlate>\n \t\b) \n\n']);
  81. correlate = 'fast';
  82. fprintf (' inputfile = ''%s'';\n', inputfile);
  83. fprintf (' maskfile = ''%s'';\n', maskfile);
  84. fprintf (' atlasfile = ''%s'';\n', atlasfile);
  85. fprintf (' correlate = ''%s'';\n', correlate);
  86. democall = ['fastECM ( inputfile, 1, 1, 1, 20, maskfile, atlasfile, 0, 25, correlate );'];
  87. fprintf ('\n %% demo call:\n >> %s\n\n', democall);
  88. if ( (exist (inputfile) *exist (maskfile) *exist (atlasfile) ) ~= 8)
  89. inputfile = inputfile (1: (end-3) );
  90. maskfile = maskfile (1: (end-3) );
  91. atlasfile = atlasfile (1: (end-3) );
  92. if (exist (inputfile) ~= 2)
  93. fprintf ('warning: not all demo files found, exiting\n');
  94. err = 1;
  95. return;
  96. end % if ~input files (uncompressed)
  97. end % if ~inputfile or ~maskfile or ~atlasfiles
  98. err = eval (democall);
  99. fprintf ('\n');
  100. return; % call fastECM inside this call
  101. else
  102. err = 0; % continue without errors
  103. end % if ~nargin
  104. % check for options for no. of dynamics,
  105. % whole matrix computation,
  106. % atlas region selection,
  107. % mask selection
  108. % max. iterations
  109. % write degree (node power) map
  110. % write normally distributed map
  111. % write ranks (uniformly distributed) map
  112. % and set defaults
  113. if (nargin<10)
  114. correlate = 'fast';
  115. if (nargin<9)
  116. dynamics = 1;
  117. if (nargin<8)
  118. wholemat = 0;
  119. if (nargin<7)
  120. atlasfile = 0;
  121. if (nargin<6)
  122. maskfile = 0;
  123. if (nargin<5)
  124. maxiter = 25;
  125. if (nargin<4)
  126. degmap = 0;
  127. if (nargin<3)
  128. normmap = 0;
  129. if (nargin<2)
  130. rankmap = 0;
  131. end % if rankmap
  132. end % if normmap
  133. end % if degmap
  134. end % if maxiter
  135. end % if maskfile
  136. end % if atlasfile
  137. end % if wholemat
  138. end % if dynamics
  139. end % if correlate
  140. % if options were given as a struct
  141. % use the existing fields
  142. if ( isstruct (inputfile) )
  143. input_parameters = inputfile;
  144. fieldnames = { 'rankmap' 'normmap' 'degmap' 'maxiter' 'maskfile' 'atlasfile' 'wholemat' 'dynamics' 'correlate' 'inputfile' };
  145. for f = 1:length (fieldnames)
  146. if isfield ( input_parameters, fieldnames{f} )
  147. eval ([ fieldnames{f} ' = input_parameters.' fieldnames{f} ';' ]);
  148. end % if isfield
  149. end % for f
  150. if isstruct (inputfile)
  151. fprintf ('error: ''inputfile'' not defined in struct, exiting\n');
  152. err = 1;
  153. return;
  154. end % if isstruct
  155. end % if isstruct
  156. % check if nifti support exists
  157. % otherwise add fastECM-supplied version
  158. if (exist ('load_untouch_nii') ~= 2)
  159. fprintf (2,'Software for reading NifTI images not found. \n');
  160. fprintf (2,'Using Tools for Nifti/Analyze for NifTI file I / O. \n');
  161. fprintf (2,'www.mathworks.com/matlabcentral/fileexchange/8797\n\n');
  162. usenifti = 1;
  163. npath = [fileparts(which('fastECM.m')) filesep 'tools4nifti'];
  164. addpath (npath);
  165. else
  166. usenifti = 0;
  167. end % if exist
  168. % load NifTI input file
  169. fprintf ('reading %s ...\n', inputfile);
  170. if (inputfile (1) ~= filesep) % if path does not start with a separator
  171. if ( (isunix) | ... % and -in windows- not with a drive letter or '\\'
  172. ( (~isunix) & (inputfile (2) ~= '\') & (inputfile (2) ~= ':') ) ...
  173. ) % make it an absolute path
  174. inputfile = [pwd filesep inputfile];
  175. end % if isunix
  176. end % if inputfile
  177. % get the directory, base name and extension (s)
  178. [fd, fn, fx2] = fileparts (inputfile); % dir and base file name + extension (may be combined)
  179. [fd1, fn, fx] = fileparts (fn); % base file name and 1st extension (2nd may be .gz)
  180. % get the data and clear data from file record
  181. M = load_untouch_nii (inputfile); % read the information from the NifTI file
  182. m = double (M.img); % get the 4d voxel data
  183. M.img = []; % empty img after reading
  184. M = rmfield (M, 'img'); % and remove from M
  185. msz = size (m);
  186. tln = msz (4); % store the time series length
  187. msz = msz (1:3); % store the size of one image volume
  188. m (find (~isfinite (m) ) ) = 0; % get rid of NaNs
  189. % check whether a mask filename has been given and if dimensions are OK
  190. msk = 1; % default value for no user-supplied mask
  191. if ( maskfile ~= 0 & ~isempty (maskfile) )
  192. if (maskfile (1) ~= filesep) % if path does not start with a separator
  193. if ( (isunix) | ... % and -in windows- not with a drive letter or '\\'
  194. ( (~isunix) & (maskfile (2) ~= '\') & (maskfile (2) ~= ':') ) ...
  195. ) % make it an absolute path
  196. maskfile = [pwd filesep maskfile];
  197. end % if isunix
  198. end % if maskfile
  199. Msk = load_untouch_nii (maskfile); % read the information from the NifTI file
  200. msk = double (Msk.img); % get the 3d voxel data
  201. Msk.img = []; % empty img after reading
  202. if (size (msk) ~= msz) % test if mask volume is the right size
  203. warning (sprintf (['dimensions of %s incompatible with %s\n' ...
  204. 'continuing with nonzero time series.'], ...
  205. maskfile, inputfile ) );
  206. mskfile = 0;
  207. msk = 1;
  208. end % if size
  209. else
  210. mskfile = 0;
  211. end % if maskfile
  212. % if the mask provided is not OK then the positions of nonzeros in the 1st volume
  213. msk = msk.*squeeze (abs (min (m, [], 4) ) ); % take the minimum of each timeseries
  214. msk = (msk>0); % make mask binary
  215. % if atlas is used, generate regional time series
  216. atl = 1; % default value for no user-supplied atlas
  217. if ( atlasfile ~= 0 & ~isempty (atlasfile) )
  218. if (atlasfile (1) ~= filesep) % if path does not start with a separator
  219. if ( (isunix) | ... % and in windos not with a drive letter or '\\'
  220. ( (~isunix) & (atlasfile (2) ~= '\') & (atlasfile (2) ~= ':') ) ...
  221. ) % make it an absolute path
  222. atlasfile = [pwd filesep atlasfile];
  223. end % if isunix
  224. end % if atlasfile
  225. Atl = load_untouch_nii (atlasfile); % read the information from the NifTI file
  226. atl = double (Atl.img); % get the 3d voxel data of atlas regions
  227. Atl.img = []; % empty img after reading
  228. if (size (atl) ~= msz) % test if atlas volume is the right size
  229. warning (sprintf (['dimensions of %s incompatible with %s\n' ...
  230. 'continuing by using all voxel time series'], ...
  231. atlasfile, inputfile ) );
  232. atlasfile = 0;
  233. atl = 1;
  234. else
  235. msk = msk.* (atl>0);
  236. end % if size
  237. else
  238. atlasfile = 0;
  239. end % if atlasfile
  240. fprintf ('\nloaded and masked\n');
  241. % make time series 2D [tln msk]
  242. m = reshape(m, [prod(msz) tln])' ; % reshape the 4d voxels as 2d: [tln msz]
  243. m = double(m (:, find (msk) ) ); % continue with only the nonzero voxels
  244. % if atlasfile found -> make regional time series
  245. if ( ~atlasfile )
  246. np = size (m, 2); % store the number of nonzero voxels
  247. else
  248. fprintf ('atlasing\n');
  249. mreg = max (atl (:) ); % highest region label
  250. atl = atl (find (msk) ); % atl now the same size as msk
  251. reg = unique (atl); % region labels: nonzero values found inside mask/atl
  252. mm = zeros (tln, length (reg) );
  253. for r = reg (:)' % construct regional means
  254. mm (:, r) = mean ( m (:, find (atl == r) ), 2 );
  255. end % for r
  256. m = mm; % continue with regional mean time series
  257. clear mm;
  258. txtfile = [fd filesep fn '_fastECMtseries.txt'];
  259. dlmwrite (txtfile, m, ' '); % write regional mean time series to text file
  260. matfile = [fd filesep fn '_fastECMtseries.mat'];
  261. save (matfile, 'm');
  262. np = r; % store the number of included regios
  263. wholemat = 1; % regional matrices are small -> provide all info
  264. end % if ~atlasfile
  265. % compute mean and var
  266. mav = mean (m); % compute the time series mean
  267. mvr = std (m); % compute the time series standard deviation
  268. mvr = mvr+eps; % prevent divisions by 0
  269. % prepare matrix
  270. m = (m - (ones (tln, 1) *mav) ) ...
  271. ./ (ones (tln, 1) *mvr); % mean 0, std 1 to make covariance matrix
  272. m = m/sqrt (tln-1); % make correlations instead (diagonal 1)
  273. % compute ECM on intervals given by the number of dynamics
  274. ddiff = tln-dynamics;
  275. for d = 1:dynamics
  276. % initialise eigenvector estimate v
  277. vprev = 0; % 'initialise' previous ECM estimate
  278. vcurr = ones (np, 1) /sqrt (np); % initialise estimate with L2-norm == 1
  279. iter = 0; % reset iteration counter
  280. dnorm = 1; % initial value for difference L2-norm
  281. cnorm = 0; % initial value for estimate L2-norm
  282. m0 = m (d: (ddiff+d), :); % use the interval for the current dynamic
  283. if (strcmp (correlate, 'relu') ) % use ReLU equation to guarantee positive M
  284. m0 = [m0; abs(m0) ]; % concatenate absolute value of time series
  285. end % if strcmp
  286. % efficient power iteration for correlated time series
  287. while ( (iter<maxiter) & (dnorm>cnorm) )
  288. vprev = vcurr; % start with previous estimate
  289. prevsum = sum (vprev); % sum of estimate
  290. if (~wholemat) % A. 'fast recipe' -> cunning re-ordering of computations
  291. vcurr_1 = m0*vprev; % 1. part one of M*v
  292. vcurr_2 = m0'*vcurr_1; % 2. part two of M*v
  293. % if ReLU correlation is used, then values are positive (modulo
  294. % some precision errors). Otherwise, this needs to be enforced
  295. if (strcmp (correlate, 'relu') )
  296. vcurr_3 = vcurr_2 .* (vcurr_2>0); % 3. remove remaining small negative values
  297. else
  298. vcurr_3 = vcurr_2+prevsum; % 3. adding sum -- same effect as [M+1]*v
  299. end % if strcmp
  300. else % B. original recipe -> provide full connectivity info
  301. vcurr_1 = (m0'*m0); % 1. M = correlations
  302. vcurr_2 = vcurr_1*vprev; % 2. M * v
  303. % if ReLU correlation is used, then values are positive (modulo
  304. % some precision errors). Otherwise, this needs to be enforced
  305. if (strcmp (correlate, 'relu') )
  306. vcurr_3 = vcurr_2+1; % 3. remove remaining small negative values
  307. else
  308. vcurr_3 = vcurr_2+1; % 3. [M+1]*v
  309. end
  310. if (~iter) % compute & write graph measures only in iteration 1
  311. vcurr_1 = vcurr_1-diag (diag (vcurr_1) );
  312. connmat_out (:, :, d) = vcurr_1;
  313. dist = 1./vcurr_1; % distance matrix <-> 1/connectivity
  314. for c = 1:np % shortest distances www.ee.columbia.edu/~marios/matlab/tips.pdf
  315. dist = min (dist, repmat (dist (:, c), [1 np]) +repmat (dist (c, :), [np 1]) );
  316. end % for c
  317. mpl = mean (dist (dist ~= inf) ); % average shortest path to other nodes -> global path length
  318. % threshold & binarise for other graph measures
  319. lv = length (vcurr_1);
  320. indi = triu (reshape (1: (lv*lv), [lv lv]), 1);
  321. if (exist ('backbone_wu') ~= 2); % get 'backbone' i.e. MST + some extra
  322. eval (['!wget -P ' fileparts(which ('fastECM.m')) ...
  323. ' -O backbone_wu.m ' ...
  324. 'sites.google.com/site/bctnet/Home/functions/backbone_wu.m']);
  325. end % if exist
  326. no0corr = vcurr_1; % make correlation matrix where 0-pairs have very low, non-zero correlation
  327. no0corr (~no0corr) = min (no0corr (:) ) -eps; % otherwise the BCT script will not add these nodes to the MST
  328. no0corr = no0corr+1;
  329. no0corr (find (diag (diag (no0corr) ) ) ) = 0;
  330. % compute MST and add nodes up to degree sqrt (#nodes) to the 'backbone'
  331. [mst clus] = backbone_wu (no0corr, fix (sqrt (lv) ) );
  332. vcurr_bin (:, :, d) = sign (clus);
  333. vcurr_mst (:, :, d) = sign (mst);
  334. % apply bct measures to vcurr_bin: communities (index per node)
  335. if (exist ('community_louvain') ~= 2);
  336. eval (['!wget -P ' fileparts(which ('fastECM.m') ) ...
  337. ' -O community_louvain.m ' ...
  338. 'sites.google.com/site/bctnet/Home/functions/community_louvain.m ']);
  339. end % if exist
  340. communities (:, d) = community_louvain (vcurr_bin (:, :, d) );
  341. % apply bct measures to vcurr_bin: betweenness (per node)
  342. if (exist ('betweenness_bin') ~= 2);
  343. eval (['!wget -P ' fileparts(which ('fastECM.m') ) ...
  344. ' -O betweenness_bin.m ' ...
  345. 'sites.google.com/site/bctnet/Home/functions/betweenness_bin.m ']);
  346. end % if exist
  347. betweenness (:, d) = betweenness_bin (vcurr_bin (:, :, d) );
  348. % apply bct measures to vcurr_bin: clustering (per node)
  349. if (exist ('clustering_coef_bu') ~= 2);
  350. eval (['!wget -P ' fileparts(which('fastECM.m') ) ...
  351. ' -O clustering_coef_bu.m ' ...
  352. ' sites.google.com/site/bctnet/Home/functions/clustering_coef_bu.m ']);
  353. end % if exist
  354. clustering (:, d) = clustering_coef_bu (vcurr_bin (:, :, d) );
  355. % apply bct measures to vcurr_bin: path length (per node)
  356. if (exist ('distance_bin') ~= 2);
  357. eval (['!wget -P ' fileparts(which ('fastECM.m') ) ...
  358. ' -O distance_bin.m ' ...
  359. ' sites.google.com/site/bctnet/Home/functions/distance_bin.m ']);
  360. end % if exist
  361. pathlengthtmp = distance_bin (vcurr_bin (:, :, d) );
  362. pathlength (:, d) = mean (pathlengthtmp);
  363. end % if ~iter
  364. end % if wholemat
  365. vcurr = vcurr_3/norm (vcurr_3, 2); % normalise L2-norm
  366. if ( (~iter) & (degmap ~= 0) )
  367. dvcurr (:, d) = vcurr_2 (:); % save 'node power' of this dynamic if requested
  368. end % if degmap
  369. iter = iter+1; % increase iteration counter
  370. dnorm = norm (vcurr-vprev, 2); % L2-norm of difference prev-curr estimate
  371. cnorm = norm (vcurr, 2) *eps; % L2-norm of current estimate
  372. fprintf ('dynamic %04d (%04d - %04d), iteration %04d, || v_i - v_ (i-1) || / || v_i * epsilon || = %0.16f / %0.16f\r', ...
  373. d, d-1, ddiff+d-1, iter, dnorm, cnorm)
  374. end % while
  375. if ( (rankmap ~= 0) | (normmap~= 0) )
  376. rvcurr (:, d) = tiedrank (vcurr) ... % tied ranks: equal values lead to equal ranks
  377. / (length (vcurr) +1); % division: from uniform [1, N] to uniform ]0, 1[
  378. if ( normmap ~= 0)
  379. mu = 0; % mean for N (0, 1) distributed centralities
  380. sig = 1; % standard deviation for N (0, 1) distribution
  381. % produce a map of gaussianised EC ranks if requested and write to normECM
  382. nvcurr (:, d) = mu+sqrt (2) *sig ... % probit function (en.wikipedia.org/wiki/Probit)
  383. * erfinv ... % based on inverse error function
  384. (2*rvcurr (:, d) -1); % uniform ]0, 1[ to N (0, 1) via inverse transform sampling
  385. end %if (normmap)
  386. end % if (rankmap)
  387. vcurr_out (:, d) = vcurr;
  388. fprintf ('\n');
  389. end % for d
  390. % write the eigenvactor centrality map to the file fastECM.nii (.gz)
  391. % and write orther centralities (node power, uniform, normal) if requested
  392. write_map (inputfile, M, msk, atl, vcurr_out, 'fastECM', sprintf ('ECM [iterations: %d]', iter) );
  393. if ( exist ('dvcurr') == 1 )
  394. write_map (inputfile, M, msk, atl, dvcurr, 'degCM', 'weighted degree centrality (node power) ');
  395. end % if dvcurr
  396. if ( (exist ('rvcurr') == 1) & rankmap )
  397. write_map (inputfile, M, msk, atl, rvcurr, 'rankECM', 'ECM [converted to ]0, 1[ ranks]');
  398. end % if rvcurr
  399. if ( exist ('nvcurr') == 1 )
  400. write_map (inputfile, M, msk, atl, nvcurr, 'normECM', 'ECM [converted to N (0, 1) values]');
  401. end % if nvcurr
  402. % if graph measures have been computed -> write them to a spreadsheet-readable
  403. % XML-file (take care that native XML may take a long time to load even for small files)
  404. if (exist ('connmat_out') == 1)
  405. % put matrices also in [vector_per_volume #volumes] format
  406. connmat_out = reshape(connmat_out, [prod(size(clus)) dynamics]);
  407. vcurr_bin = reshape(vcurr_bin, [prod(size(clus)) dynamics]);
  408. vcurr_mst = reshape(vcurr_mst, [prod(size(clus)) dynamics]);
  409. write_map (inputfile, M, ones (size (clus) ), 1, connmat_out, 'connections', 'connectivity matrix');
  410. write_map (inputfile, M, ones (size (clus) ), 1, vcurr_bin, 'backbone', 'binary backbone');
  411. write_map (inputfile, M, ones (size (clus) ), 1, vcurr_mst, 'min_span', 'minimal spanning tree');
  412. write_map (inputfile, M, msk, atl, communities, 'communities', 'community_louvain');
  413. write_map (inputfile, M, msk, atl, betweenness, 'betweenness', 'betweenness');
  414. write_map (inputfile, M, msk, atl, clustering, 'clustering', 'clustering');
  415. write_map (inputfile, M, msk, atl, pathlength, 'path_length', 'pathlength');
  416. % also make readable files: .mat and office-compatible XML
  417. matfile =[fd filesep fn '_fastECMstats.mat'];
  418. xmlfile = [fd filesep fn '_fastECMstats.xml'];
  419. fastECMstats.fastECM = vcurr_out;
  420. fid = fopen (xmlfile, 'w');
  421. if (fid> (-1) )
  422. fprintf (fid, '<?xml version = "1.0" encoding = "UTF-8" standalone = "yes"?>\n');
  423. fprintf (fid, ['<ss:Workbook xmlns:ss = "urn:schemas-microsoft-com:office:spreadsheet">\n']);
  424. writetosheet (fid, vcurr_out, 'fastECM');
  425. if ( exist ('dvcurr') == 1 )
  426. writetosheet (fid, dvcurr, 'degCM');
  427. fastECMstats.degCM = dvcurr;
  428. end
  429. if ( (exist ('rvcurr') == 1) & rankmap )
  430. writetosheet (fid, rvcurr, 'rankECM');
  431. fastECMstats.rankECM = rvcurr;
  432. end
  433. if ( exist ('nvcurr') == 1 )
  434. writetosheet (fid, nvcurr, 'normECM');
  435. fastECMstats.normECM = nvcurr;
  436. end
  437. % these variables cannot be written to spreadsheet
  438. % for some reason, but they can be saved as a .mat
  439. %
  440. %writetosheet (fid, connmat_out, 'connections'); % crashes spreadsheet program
  441. fastECMstats.connections = connmat_out;
  442. %writetosheet (fid, vcurr_bin, 'backbone'); % crashes spreadsheet program
  443. fastECMstats.backbone = vcurr_bin;
  444. writetosheet (fid, communities, 'communities');
  445. fastECMstats.communities = communities;
  446. writetosheet (fid, betweenness, 'betweenness');
  447. fastECMstats.betweenness = betweenness;
  448. writetosheet (fid, clustering, 'clustering');
  449. fastECMstats.clustering = clustering;
  450. writetosheet (fid, pathlength, 'path_length');
  451. fastECMstats.path_length = pathlength;
  452. fprintf (fid, '</ss:Workbook>\n');
  453. fclose (fid);
  454. % write fastECMstats to a .mat file
  455. save (matfile,'fastECMstats');
  456. end % if fid
  457. end % if connmat_out
  458. % if nifti support was added before, remove it again to not leave prints
  459. if (usenifti)
  460. rmpath (npath); % was own nifti added to path -- if yes then remove now
  461. end % if usenifti
  462. return % fastECM
  463. % tiedrank - Tied rank of each element in a set
  464. % [r] = tiedrank (X, dim)
  465. % Computes tied rank of each element of X along given dimension
  466. % (default is to use the first non-singleton dimension)
  467. % "Tied ranking" is such that ex-aequo elements share the same (possibly half) rank:
  468. % >> tiedrank (['DABBC']) %-> 6 1 2.5 2.5 4
  469. % from https://github.com/kndiaye/matlab/blob/master/tiedrank.m
  470. function [r] = tiedrank (X, dim)
  471. if nargin<2
  472. dim = min (find (size (X) >1) );
  473. if isempty (dim)
  474. error ('X is empty!')
  475. end % if isempty
  476. end % if nargin
  477. [ignore, Y] = sort (X, dim);
  478. [ignore, r1] = sort (Y, dim);
  479. [ignore, Y] = sort (-X, dim);
  480. [ignore, r2] = sort (Y, dim);
  481. r2 = size (X, dim) -r2+1;
  482. r = (r1+r2) /2;
  483. return
  484. % function to write a variable as an XML sheet
  485. % the option of writing flattened upper triangular matrices is implemented but never used!
  486. function writetosheet (fid, variable, sheetname);
  487. fprintf (fid, '<ss:Worksheet ss:Name = "%s">\n<ss:Table>\n', sheetname);
  488. if (length (size (variable) ) == 3)
  489. for m = 1:size (variable, 3) % write matrix by flattening upper triangular matrix
  490. variable2d (:, m) = nonzeros (triu (squeeze (variable (:, :, m) ), 1) );
  491. end % for m
  492. variable = variable2d;
  493. clear variable2d;
  494. end % if length
  495. for c = 1:size (variable, 2)
  496. fprintf (fid, '<ss:Row>\n');
  497. for r = 1:size (variable, 1)
  498. fprintf (fid, '<ss:Cell><ss:Data ss:Type = "Number">%0.8f</ss:Data></ss:Cell>', variable (r, c) );
  499. end % for r
  500. fprintf (fid, '</ss:Row>\n');
  501. end % for c
  502. fprintf (fid, '</ss:Table>\n</ss:Worksheet>\n');
  503. return
  504. % function to write a map/matrix as a nifti file
  505. function write_map (inputfile, M, msk, atl, vcurr, mapfile, descrip)
  506. %
  507. % writes a map based on a template file
  508. % - inputfile = filename of the template
  509. % - M = nifti record of the template
  510. % - msk = brain mask of the template
  511. % - atl = atlas volume (if used, otherwise 1)
  512. % - vcurr = map values inside brain mask
  513. % - mapfile = filename of the map file
  514. % - descrip = description of contents
  515. %
  516. %
  517. %
  518. % this routine uses the following external code
  519. %
  520. % " Tools for Nifti / Analyze " by Jimmy Shen
  521. % http://www.mathworks.com/matlabcentral/fileexchange/8797
  522. % " quantile.m " by Anders Holtsberg
  523. % www.spatial-econometrics.com/distrib/quantile.m
  524. %
  525. % if atlas used, make a map of regional centralities
  526. if (prod (size (atl) ) ~= 1)
  527. vcurr_2 = zeros (size (atl) );
  528. reg = unique (atl); % region labels: nonzero values found inside atl
  529. for d = 1:size (vcurr, 2)
  530. for r = 1:length (reg)
  531. nvox = find (atl == reg (r) );
  532. vcurr_2 (nvox, d) = vcurr (r, d);%/ (length (nvox) );
  533. end % for r
  534. end % for d
  535. vcurr = vcurr_2;
  536. clear vcurr_2;
  537. end % if prod
  538. % create output array mout (and initialise 0)
  539. mout = zeros ([size(msk) size(vcurr, 2)]);
  540. mout = nan*mout; % NaN outside mask
  541. qnts = quantiles (vcurr ...
  542. (vcurr>0), ...
  543. [.01 .99]); % quantiles to set contrast
  544. % put vcurr in mout
  545. smout = size (mout);
  546. mout = reshape (mout, [prod(size(msk)) size(vcurr, 2)]);
  547. mout (find (msk), :) = vcurr;
  548. mout = reshape (mout, smout);
  549. % write output nifti file based on mout
  550. [fd, fn, fx2] = fileparts (inputfile);
  551. [fd1, fn, fx] = fileparts (fn); % base file name and 1st extension (2nd may be .gz)
  552. fx = [fx fx2]; % in which case, concatenate by adding fx2
  553. outputfile = [fd filesep fn '_' mapfile fx];
  554. fprintf ('writing %s ...\n', outputfile);
  555. M.hdr.hist.descrip = sprintf ('generated by fastECM - %s', descrip);
  556. M.hdr.dime.dim = [ length(size(mout)) size(mout) ];
  557. M.hdr.dime.dim ( (end+1) :8) = 1; % map is not 4D
  558. M.hdr.dime.pixdim ( (end+1) :8) = 1; % neither are its voxels
  559. if ~max ([32, 64] == M.hdr.dime.bitpix) % if data type not at least float
  560. M.hdr.dime.datatype = 64; % make it double
  561. end;
  562. M.hdr.dime.cal_min = qnts (1); % min of range (for win/lev)
  563. M.hdr.dime.cal_max = qnts (2); % max
  564. M.hdr.dime.glmin = qnts (1); % min of range
  565. M.hdr.dime.glmax = qnts (2); % max
  566. M.hdr.dime.scl_slope = 1; % the quantiles only make sense
  567. M.hdr.dime.scl_inter = 0; % with slope 1 and intercept 0
  568. M.img = mout; % add voxel data to map
  569. save_untouch_nii (M, outputfile); % write the file
  570. return

fastECM.m at commit d0c2b7e, under GPL-3.0 · at the source

Overview

Authors: Takamichi Tohyama1,2, Reona Yamaguchi3,4, Naokazu Goda1,5,6, Tetsuya Yamamoto1,5,7, Norihiro Sadato5,7,8, Tadashi Isa3,4,5,9, Masaki Fukunaga1,5,6
  1. Section of Brain Function Information, National Institute for Physiological Sciences,38 Nishigonaka, Myodaiji, Okazaki, 444-8585 Japan
  2. Department of Rehabilitation Medicine, School of Medicine, Fujita Health University,1-98 Dengakugakubo, Kutsukake, Toyoake, 470-1192 Japan
  3. Institute for the Advanced Study of Human Biology (WPI-ASHBi), Kyoto University,Yoshida-konoe-cho, Sakyo-ku, Kyoto, 606-8501 Japan
  4. Department of Neuroscience, Graduate School of Medicine, Kyoto University,Yoshida-konoe-cho, Sakyo-ku, Kyoto, 606-8501 Japan
  5. Core for Spin Life Sciences, Okazaki Collaborative Platform, National Institutes of Natural Sciences,38 Nishigonaka, Myodaiji, Okazaki, 444-8585 Japan
  6. Physiological Science Program, Graduate Institute for Advanced Studies, SOKENDAI, Shonan Village,Hayama, 240-0193 Japan
  7. Research Organization of Science and Technology, Ritsumeikan University,1-1-1 Noji-Higashi, Kusatsu, 525-8577 Japan
  8. Center for Research Collaboration, National Institute for Physiological Sciences,38 Nishigonaka, Myodaiji, Okazaki, 444-8585 Japan
  9. Section of Advanced Project Promotion, National Institute for Physiological Sciences,38 Nishigonaka, Myodaiji, Okazaki, 444-8585 Japan
Journal: Scientific reports, volume 16, issue 1, article 24253
Dates: received 27 March 2025; accepted 19 May 2026; published online 27 May 2026
Type: Research article · Language: English
License: CC BY-NC-ND
Identifiers: DOI 10.1038/s41598-026-54528-7 · PMID 42204263 · PMCID PMC13443211 · OpenAlex W7162523560
Open access: gold, a free copy (OpenAlex)
Status: code verified
Categories: fMRI (modality), non-human primate (organism), other condition (population), systems (subfield)
Methods: Spectral & time-frequency, Statistics, Preprocessing, Connectivity, fMRI & imaging, Smoothing, state filtering, decompositions, Physiology & signal measures
Keywords: Neuronal network, Brain plasticity, Functional neuroimaging, Sensorimotor area, Motor cortex, Premotor cortex, Cortex, Spinal cord injury, Functional magnetic resonance imaging
MeSH: Hand*, Motor Cortex*, Recovery of Function*, Sensorimotor Cortex*, Spinal Cord Injuries*, Animals, Magnetic Resonance Imaging, Male (* major topic)
Topic: Transcranial Magnetic Stimulation Studies (Neurology, Neuroscience), according to OpenAlex
Funding: Japan Society for the Promotion of Science (JP22K15624, JP22H04992, JP19K22985); Japan Agency for Medical Research and Development (JP18dm0307005, JP17dm0107118)
Citations: not cited yet (Europe PMC); 55 references in the paper

Abstract

The abstract is not reproduced here: the paper's license (CC BY-NC-ND) does not allow it. Read it in the paper, at the publisher or on Europe PMC.

Repository

Its files are read in the Code ↔ Paper reader above, with 3 matches between paragraphs and lines of code.

amwink/bias

License: GPL-3.0
State: the link answers, verified on 28 September 2026
Evidence: files inventoried
Commit: d0c2b7ecd16b0c6f638a00c596c59b899fc13e0b, 25 August 2022
Languages: MATLAB (132), C (13), Shell (6), Python (5), C/C++ (2), C++ (1)
Size: 186 files, 159 scripts
Software Heritage: archived
Found in: the text, “Statistical analysis”
Holds: README, license file
Not found: CITATION.cff, environment file, tests, continuous integration, documentation
Tools: Tools for NIfTI and ANALYZE image (MATLAB) (15 files), SPM (14 files), FSL (4 files), NiBabel (3 files), NumPy (3 files), Brain Connectivity Toolbox (1 file), DIPY (1 file), Image Processing Toolbox (1 file), Matplotlib (1 file), pydicom (1 file), SciPy (1 file)
Availability: 1 check, the latest on 28 September 2026: the link answers
  • 28 September 2026: the link answers
161 files

Tracing map

Proposed by the machine: these links were found in the paper and verified at the source, without human review. The map will receive a Zenodo DOI once one of the paper's authors has validated it with their ORCID.

What the map holds:

  • 1 repository of the authors' code, each at its verified commit, with its license and how the link was found in the paper;
  • 159 scripts, each with its path and the digest of its content;
  • 3 matches between paragraphs of the paper and lines of the code (method lexical-v1);
  • neither the text of the paper nor the code itself.

Its JSON (tracing-map.json) is deposited on Zenodo with its DOI once the map is validated.

Data

No dataset and no data link were found in the paper.

Data availability statement

The paper has a data availability statement. Its license (CC BY-NC-ND) does not allow reproducing it here; in short, from what the harvester recognized in it:

  • it says that the data are available on request

Read it in the paper: doi.org/10.1038/s41598-026-54528-7.

Versions

The history of this record: each version stored by the harvester or made by a correction of its authors or of the maintainers of its code, and what changed in its facts. The texts of the paper (its abstract, its availability statements) are not part of it; versions that changed only those are not listed.

Version 1, 28 September 2026: the first record

Recorded: type, language, journal, volume, issue, pages, dates, 7 authors, 9 keywords, 8 MeSH terms, 2 funders, 55 references.

Cite

This paper

Tohyama, T., Yamaguchi, R., Goda, N., Yamamoto, T., Sadato, N., Isa, T., & Fukunaga, M. (2026). Enhanced sensorimotor cortex responsiveness to nonplegic hand stimulation and motor network assembly during recovery after spinal cord injury in primates. Scientific reports, 16(1), 24253. https://doi.org/10.1038/s41598-026-54528-7

BibTeX

@article{tohyama2026enhanced,
author = {Tohyama, Takamichi and Yamaguchi, Reona and Goda, Naokazu and Yamamoto, Tetsuya and Sadato, Norihiro and Isa, Tadashi and Fukunaga, Masaki},
title = {{Enhanced sensorimotor cortex responsiveness to nonplegic hand stimulation and motor network assembly during recovery after spinal cord injury in primates}},
journal = {Scientific reports},
year = {2026},
month = may,
volume = {16},
number = {1},
pages = {24253},
publisher = {Nature Publishing Group},
issn = {2045-2322},
doi = {10.1038/s41598-026-54528-7},
url = {https://doi.org/10.1038/s41598-026-54528-7},
pmid = {42204263},
pmcid = {PMC13443211}
}

RIS

TY - JOUR
AU - Tohyama, Takamichi
AU - Yamaguchi, Reona
AU - Goda, Naokazu
AU - Yamamoto, Tetsuya
AU - Sadato, Norihiro
AU - Isa, Tadashi
AU - Fukunaga, Masaki
TI - Enhanced sensorimotor cortex responsiveness to nonplegic hand stimulation and motor network assembly during recovery after spinal cord injury in primates
T2 - Scientific reports
J2 - Sci Rep
PY - 2026
DA - 2026/05/27
VL - 16
IS - 1
SP - 24253
SN - 2045-2322
PB - Nature Publishing Group
DO - 10.1038/s41598-026-54528-7
UR - https://doi.org/10.1038/s41598-026-54528-7
LA - en
ER -

CSL-JSON

{
"id": "10.1038/s41598-026-54528-7",
"type": "article-journal",
"title": "Enhanced sensorimotor cortex responsiveness to nonplegic hand stimulation and motor network assembly during recovery after spinal cord injury in primates",
"container-title": "Scientific reports",
"author": [
{
"family": "Tohyama",
"given": "Takamichi"
},
{
"family": "Yamaguchi",
"given": "Reona"
},
{
"family": "Goda",
"given": "Naokazu"
},
{
"family": "Yamamoto",
"given": "Tetsuya"
},
{
"family": "Sadato",
"given": "Norihiro"
},
{
"family": "Isa",
"given": "Tadashi"
},
{
"family": "Fukunaga",
"given": "Masaki"
}
],
"container-title-short": "Sci Rep",
"volume": "16",
"issue": "1",
"page": "24253",
"DOI": "10.1038/s41598-026-54528-7",
"PMID": "42204263",
"PMCID": "PMC13443211",
"ISSN": "2045-2322",
"publisher": "Nature Publishing Group",
"URL": "https://doi.org/10.1038/s41598-026-54528-7",
"language": "en",
"issued": {
"date-parts": [
[
2026,
5,
27
]
]
}
}

The tracing map gets a citation of its own once an author has validated it and it has a DOI.

Similar papers

The papers with a page that share the most with this one: the tools found in their code, their categories, datasets, cited references and authors, the rarest counting most.

[1] doi:10.7554/elife.108408 [code]
Frequency and laminar profile of feature-specific visual activity revealed by interleaved EEG-fMRI.
Journal: eLife
In common: DIPY, Tools for NIfTI and ANALYZE image (MATLAB), FSL, 6 other tools, fMRI, systems
[2] doi:10.1162/imag.a.1262 [code]
Frame-wise multi-echo distortion correction for superior functional MRI.
Journal: Imaging neuroscience (Cambridge, Mass.)
In common: pydicom, Tools for NIfTI and ANALYZE image (MATLAB), FSL, 6 other tools, fMRI
[3] doi:10.1038/s41586-026-10631-3 [code]
A prognostic human brain network for diffuse midline glioma.
Journal: Nature
In common: pydicom, Tools for NIfTI and ANALYZE image (MATLAB), FSL, 6 other tools, other condition
[4] doi:10.1002/mrm.70336 [code]
Offline Reconstruction of Diffusion MRI Acquisitions for Comparison Between Complex PCA-Based and AI-Based Denoising.
Journal: Magnetic resonance in medicine
In common: DIPY, Tools for NIfTI and ANALYZE image (MATLAB), FSL, 6 other tools
[5] doi:10.1111/nyas.70349 [code]
FREQ-NESS Reveals Age-Related Differences in Frequency-Resolved Brain Networks During Auditory Recognition and Resting State.
Journal: Annals of the New York Academy of Sciences
In common: Brain Connectivity Toolbox, Tools for NIfTI and ANALYZE image (MATLAB), FSL, 6 other tools
[6] doi:10.1038/s41398-026-04025-2 [code]
Brain energetic landscapes shape state dysregulation in major depressive disorder: a morphological network controllability perspective.
Journal: Translational psychiatry
In common: Brain Connectivity Toolbox, Tools for NIfTI and ANALYZE image (MATLAB), FSL, 6 other tools
[7] doi:10.1038/s41467-026-76011-7 [code]
Human cortex organizes dynamic co-fluctuations along the sensorimotor-association axis.
Journal: Nature communications
In common: Brain Connectivity Toolbox, FSL, SPM, 5 other tools, systems, 1 reference
[8] doi:10.1186/s13293-026-00891-z [code]
Sex differences in dynamic and static measures of brain integration derived from resting-state functional magnetic resonance imaging.
Journal: Biology of sex differences
In common: DIPY, pydicom, FSL, 5 other tools, fMRI
[9] doi:10.1038/s41467-026-73668-y [code]
Convergent and divergent brain-cognition development in early adolescence.
Journal: Nature communications
In common: Tools for NIfTI and ANALYZE image (MATLAB), FSL, SPM, 5 other tools, fMRI, 1 reference
[10] doi:10.1002/hbm.70483 [code]
Untamed: Unconstrained Tensor Decomposition and Graph Node Embedding for Cortical Parcellation.
Journal: Human brain mapping
In common: Tools for NIfTI and ANALYZE image (MATLAB), FSL, SPM, 5 other tools, fMRI, 1 reference

Contribute

The authors of this paper can claim it, correct its record and validate its tracing map, and the maintainers of its code (its owner, or a public member of its organization) correct what it says of their repository; anyone signed in can ask for its removal. Every request goes to OSCR's own machine, which answers it; your account page follows them.

Sign in with ORCID to claim this paper as one of its authors, correct its record or validate its tracing map: when the paper's metadata lists your ORCID iD, you are recognized at once. Maintainers of its code: sign in with GitHub, then claim the repository on your account page.

Request its removal

To ask OSCR to remove this record, the copies of its authors' scripts or its tracing map, use the removal request page: signed in, you say who you are, what to remove and why, then review and confirm the request. Published rules decide every request (how).

Discussion, reproductions, activity

Discussion: questions and error reports about this paper and its code, from signed-in readers and its authors. It opens with sign-in.

Reproductions: reports from readers who ran the authors' code: what they reproduced, with which environment, commit and data. It opens with sign-in.

Activity: what happens around this paper: new versions of its record, its map's validation, discussions and reproductions. It opens with sign-in.