Prep fMRI data for connectivity or computational model-based anlayses
Below is a step‐by‐step tutorial for pre‐processing fMRI data for connectivity analyses and custom linear or computational reinforcement learning (RL) models using CANLAB tools. In this example, we create a denoised 4-D time series (an fmri_data object) for each participant, then use it for downstream analyses. The CANLAB toolboxes (see CANLAB.github.io) offer functions for most of these steps. Feel free to adapt the code snippets to your specific dataset and analysis goals. See also:
canlab_connectivity_preproc()
% Some formatting stuff for html
set(groot, 'DefaultFigurePosition', [200, 200, 900, 600], 'DefaultAxesFontSize', 12);
Pipeline for denoising multi-run 4-D time series image data
denoise_timeseries_pipeline prepares 4-D time series images from a participant for connectivity or model-based analysis.
See also canlab_connectivity_preproc
% Load the key 4-D image file into an object:
fname = which('swrsub-sid001567_task-pinel_acq-s1p2_run-03_bold.nii.gz');
obj = fmri_data(fname);
Using default mask: /Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/brainmask_canlab.nii
loading mask. mapping volumes.
checking that dimensions and voxel sizes of volumes are the same.
Pre-allocating data array. Needed: 145720800 bytes
Loading image number: 150
Elapsed time is 0.455582 seconds.
Image names entered, but fullpath attribute is empty. Getting path info.
.fullpath should have image name for each image column in .dat
Attempting to expand image filenames in case image list is unexpanded 4-D images
Number of unique values in dataset: 493 Bit rate: 8.95 bits
Warning: Number of unique values in dataset is low, indicating possible restriction of bit rate. For comparison, Int16 has 65,536 unique values
% Get the TR from the JSON file:
json_struct = jsondecode(fileread(which('sub-sid001567_task-pinel_acq-s1p2_run-03_bold.json')));
TR = json_struct.RepetitionTime;
% Specify the movement parameter file:
mvmtfname = which('rp_sub-sid001567_task-pinel_acq-s1p2_run-03_bold.txt');
% Run the denoising pipeline:
obj_denoised = obj.denoise_timeseries_pipeline(TR, 128, mvmtfname, 'plot', true, 'verbose', true);
Starting denoise_timeseries_pipeline
Loading movement regressors...
Computing outlier regressors...
______________________________________________________________
Outlier analysis
______________________________________________________________
global mean | global mean to var | spatial MAD | rmssd | Missing values | 0 images
Retained 2 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 18.67%
Expected 7.50 outside 95% ellipsoid, found 6
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 1 images Cases 1
Uncorrected: 6 images Cases 1 2 3 4 5 6
Retained 2 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 22.67%
Expected 7.50 outside 95% ellipsoid, found 6
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 1 images Cases 1
Uncorrected: 6 images Cases 1 2 3 4 5 6
Mahalanobis (cov and corr, q<0.05 corrected):
1 images
Framewise Displacement (before and after >0.50 mm correction):
0 images
Outlier_count Percentage
_____________ __________
global_mean 6 4
global_mean_to_variance 4 2.6667
missing_values 0 0
rmssd_dvars 1 0.66667
spatial_variability 4 2.6667
mahal_cov_uncor 6 4
mahal_cov_corrected 1 0.66667
mahal_corr_uncor 6 4
mahal_corr_corrected 1 0.66667
fd 0 0
Overall_uncorrected 10 6.6667
Overall_corrected 8 5.3333
Number of outlier volumes (uncorrected): 10
Extracting mean CSF signal...
Extracting from gray_matter_mask_sparse.img.
Removing 2565 voxels with one or more NaNs
Extracting from canonical_white_matter.img.
Removing 106 voxels with one or more NaNs
Extracting from canonical_ventricles.img.
Removing 158 voxels with one or more NaNs
Applying high-pass filter...
Regressing out nuisance covariates...
Denoised metadata table:
mvmt_x mvmt_y mvmt_z mvmt_roll mvmt_pitch mvmt_yaw mvmt_x^2 mvmt_y^2 mvmt_z^2 mvmt_roll^2 mvmt_pitch^2 mvmt_yaw^2 mvmt_xdiff mvmt_ydiff mvmt_zdiff mvmt_rolldiff mvmt_pitchdiff mvmt_yawdiff mvmt_xdiff^2 mvmt_ydiff^2 mvmt_zdiff^2 mvmt_rolldiff^2 mvmt_pitchdiff^2 mvmt_yawdiff^2 Out1 Out2 Out3 Out4 Out5 Out6 Out7 Out8 Out9 Out10 MeanCSF KH1 KH2 KH3 KH4
_________ __________ __________ _________ ___________ _________ __________ __________ __________ ___________ ____________ __________ ___________ __________ ___________ _____________ ______________ ____________ ____________ ____________ ____________ _______________ ________________ ______________ ____ ____ ____ ____ ____ ____ ____ ____ ____ _____ _______ __________ ___________ _________ __________
-0.15734 -1.1991 3.2993 1.2974 -1.8213 -1.0474 0.024756 1.4379 10.885 1.6833 3.3172 1.0971 0 0 0 0 0 0 0.0058857 1.0776e-05 0.007354 0.0094301 0.00028598 0.015048 1 0 0 0 0 0 0 0 0 0 303.4 0.11546 0.11544 0.11541 0.11537
-0.49252 -1.3582 3.8513 1.2745 -2.8581 -1.2734 0.24258 1.8448 14.833 1.6242 8.1685 1.6215 -0.33518 -0.1591 0.55207 -0.022944 -1.0367 -0.22597 6.5524 0.0095731 3.1375 0.00065022 9.3308 4.3304 0 1 0 0 0 0 0 0 0 0 305.27 0.11541 0.11524 0.11496 0.11456
-1.3909 -0.76668 3.8426 1.1925 -4.3719 -1.9456 1.9346 0.5878 14.766 1.4221 19.113 3.7852 -0.89839 0.59156 -0.0087285 -0.081951 -1.5138 -0.67218 45.321 0.12131 0.0034935 0.11616 19.824 35.378 0 0 1 0 0 0 0 0 0 0 304.56 0.11531 0.11484 0.11405 0.11295
-1.6729 -0.44907 3.6899 1.0493 -4.1512 -1.9579 2.7984 0.20166 13.615 1.101 17.232 3.8335 -0.28194 0.31762 -0.15272 -0.14324 0.22069 -0.012385 4.6889 0.034405 0.1448 0.44666 0.39654 0.052901 0 0 0 1 0 0 0 0 0 0 305.13 0.11516 0.11423 0.11269 0.11054
-1.7716 1.2247 3.4342 1.0013 -3.4948 -2.1775 3.1384 1.4999 11.794 1.0026 12.214 4.7416 -0.098712 1.6738 -0.25568 -0.047956 0.6564 -0.21958 0.65285 0.98306 0.48284 0.025333 3.6342 4.1031 0 0 0 0 1 0 0 0 0 0 305.5 0.11496 0.11342 0.11089 0.10736
-2.1816 -1.7807 2.781 1.6438 -2.9914 -2.4684 4.7593 3.171 7.7338 2.7022 8.9483 6.0932 -0.41002 -3.0054 -0.65323 0.64251 0.50342 -0.29092 9.6982 3.2023 3.643 12.465 2.1261 6.99 0 0 0 0 0 1 0 0 0 0 306.53 0.1147 0.11242 0.10864 0.10343
-2.2071 0.19207 2.381 1.6966 -2.1391 -2.3392 4.8713 0.036893 5.6693 2.8784 4.576 5.4721 -0.025525 1.9728 -0.39994 0.05275 0.85223 0.1292 0.070657 1.367 1.2889 0.14364 6.1512 0.99405 0 0 0 0 0 0 1 0 0 0 307.61 0.1144 0.11122 0.10597 0.098769
-1.9208 -0.25819 1.8876 1.8703 -1.5973 -2.0534 3.6895 0.066663 3.5629 3.4981 2.5513 4.2163 0.2863 -0.45027 -0.49348 0.17375 0.54187 0.28588 4.1788 0.073381 2.019 1.0519 2.4674 5.5452 0 0 0 0 0 0 0 1 0 0 307.45 0.11405 0.10982 0.10288 0.093417
-1.6532 0.10572 1.2791 1.9866 -0.30261 -1.6557 2.7331 0.011178 1.636 3.9464 0.091573 2.7412 0.26762 0.36392 -0.6085 0.11624 1.2947 0.39769 3.6321 0.04537 3.1403 0.51589 14.262 11.048 0 0 0 0 0 0 0 0 1 0 308.45 0.11365 0.10823 0.09939 0.08741
-1.39 0.76089 0.58947 1.9495 -0.21464 -1.5776 1.9322 0.57896 0.34748 3.8006 0.04607 2.4889 0.26315 0.65517 -0.68958 -0.037044 0.087971 0.078032 3.5071 0.14908 4.079 0.010171 0.058009 0.30644 0 0 0 0 0 0 0 0 0 0 307.55 0.11319 0.10645 0.095503 0.08079
-1.4473 -1.0571 1.0689 2.061 -0.022412 -1.504 2.0947 1.1174 1.1425 4.2477 0.00050229 2.2621 -0.057266 -1.818 0.47942 0.11148 0.19223 0.073628 0.25095 1.1745 2.4009 0.48005 0.29847 0.26565 0 0 0 0 0 0 0 0 0 0 307.8 0.11269 0.10448 0.091239 0.073603
-1.4445 -0.051963 0.81845 1.8435 -0.26366 -1.6727 2.0865 0.0027002 0.66986 3.3986 0.069518 2.7978 0.0028397 1.0051 -0.25044 -0.21746 -0.24125 -0.16865 0.0031005 0.35293 0.46087 1.1342 0.52387 2.5099 0 0 0 0 0 0 0 0 0 0 307.51 0.11214 0.10233 0.086615 0.0659
-1.4448 -1.6969 1.1674 1.9769 -0.16715 -1.5592 2.0875 2.8796 1.3629 3.908 0.02794 2.4312 -0.00033265 -1.645 0.349 0.13334 0.09651 0.11345 0.0062699 0.96225 1.3255 0.65556 0.070687 0.74049 0 0 0 0 0 0 0 0 0 0 307.28 0.11154 0.1 0.08165 0.057735
-1.0211 0.43626 1.0126 1.8334 -0.039812 -1.3648 1.0427 0.19032 1.0254 3.3612 0.001585 1.8628 0.42368 2.1332 -0.1548 -0.14352 0.12734 0.19438 9.3757 1.5991 0.14968 0.44869 0.12688 2.4393 0 0 0 0 0 0 0 0 0 0 307.66 0.11089 0.097495 0.076362 0.049165
-1.0815 -1.518 0.8008 1.9916 -0.24335 -1.322 1.1697 2.3043 0.64128 3.9665 0.05922 1.7478 -0.060411 -1.9542 -0.21184 0.15824 -0.20354 0.042803 0.27484 1.3566 0.31476 0.88871 0.37613 0.061639 0 0 0 0 0 0 0 0 0 0 307.87 0.11019 0.094818 0.070772 0.04025
-0.94266 0.20214 0.82532 1.7012 -0.17976 -1.3006 0.88861 0.040862 0.68115 2.8941 0.032312 1.6915 0.13887 1.7201 0.024518 -0.2904 0.063597 0.021473 0.90639 1.0385 0.025796 2.1164 0.028707 0.0040218 0 0 0 0 0 0 0 0 0 0 307.28 0.10944 0.091975 0.064904 0.031052
-1.0518 -2.3648 0.93155 1.7947 -0.51561 -1.3457 1.1063 5.5924 0.86778 3.2208 0.26585 1.8109 -0.10913 -2.567 0.10623 0.093474 -0.33585 -0.045133 0.7835 2.3376 0.16818 0.35595 1.0019 0.264 0 0 0 0 0 0 0 0 0 0 308.11 0.10864 0.088971 0.058779 0.021637
-0.97934 0.14658 0.70868 1.5625 -0.27504 -1.3965 0.95911 0.021487 0.50223 2.4415 0.075644 1.9502 0.072447 2.5114 -0.22287 -0.23213 0.24057 -0.050806 0.21158 2.2181 0.35366 1.3072 0.47331 0.31693 0 0 0 0 0 0 0 0 0 0 307.75 0.1078 0.085811 0.052422 0.01207
-1.1525 -1.7327 0.86596 1.7382 -0.12218 -1.3544 1.3283 3.0023 0.74989 3.0214 0.014927 1.8343 -0.17316 -1.8793 0.15728 0.17569 0.15286 0.042151 1.8482 1.2548 0.3203 1.0732 0.18574 0.058864 0 0 0 0 0 0 0 0 0 0 308.63 0.10691 0.0825 0.045859 0.0024182
-0.97037 1.1189 0.92381 1.1774 0.024774 -1.3963 0.94162 1.252 0.85342 1.3862 0.00061376 1.9498 0.18213 2.8516 0.057843 -0.56087 0.14695 -0.041991 1.6193 2.8613 0.068833 8.4107 0.17111 0.23676 0 0 0 0 0 0 0 0 0 0 307.78 0.10597 0.079045 0.039114 -0.0072504
-1.0712 -1.7873 1.239 1.4587 0.022359 -1.3257 1.1475 3.1946 1.5351 2.1277 0.00049993 1.7575 -0.10086 -2.9063 0.31519 0.28131 -0.002415 0.070653 0.6788 2.9949 1.0985 2.5613 0.00057538 0.23974 0 0 0 0 0 0 0 0 0 0 307.28 0.10499 0.075451 0.032215 -0.016868
-1.0441 0.30213 1.1084 1.1174 0.22826 -1.3538 1.0901 0.091285 1.2287 1.2486 0.052104 1.8328 0.027158 2.0895 -0.13055 -0.34126 0.2059 -0.02811 0.015492 1.534 0.097867 2.9808 0.34386 0.13416 0 0 0 0 0 0 0 0 0 0 307.24 0.10396 0.071724 0.025189 -0.026368
-1.0828 -1.3647 1.0829 1.2542 -0.12194 -1.3504 1.1724 1.8624 1.1726 1.573 0.01487 1.8237 -0.038723 -1.6668 -0.02557 0.13679 -0.35021 0.0033691 0.13219 0.98791 5.9081e-05 0.68577 1.0879 0.0087372 0 0 0 0 0 0 0 0 0 0 307.14 0.10288 0.067872 0.018063 -0.035682
-1.0344 0.99192 1.3479 0.79244 0.8439 -1.4029 1.07 0.9839 1.8168 0.62796 0.71217 1.9682 0.048405 2.3566 0.26501 -0.46176 0.96585 -0.052494 0.079453 1.9525 0.80082 5.6191 7.9134 0.33362 0 0 0 0 0 0 0 0 0 0 307.24 0.10176 0.0639 0.010867 -0.044746
-1.0897 -0.3552 1.3966 0.64228 0.84837 -1.485 1.1874 0.12617 1.9504 0.41253 0.71973 2.2053 -0.05528 -1.3471 0.048677 -0.15016 0.0044668 -0.082084 0.23643 0.64628 0.054931 0.49748 1.4617e-05 0.69561 0 0 0 0 0 0 0 0 0 0 306.88 0.1006 0.059817 0.003627 -0.053497
-1.2111 0.26729 1.4066 0.4079 0.90869 -1.5302 1.4669 0.071444 1.9786 0.16638 0.82571 2.3415 -0.12147 0.62249 0.010055 -0.23439 0.060321 -0.045198 0.95369 0.13446 0.013562 1.335 0.025546 0.26457 0 0 0 0 0 0 0 0 0 0 307.63 0.09939 0.055628 -0.003627 -0.061872
-1.3604 -0.97276 1.1072 0.5413 0.43431 -1.567 1.8508 0.94626 1.2259 0.29301 0.18862 2.4555 -0.14931 -1.24 -0.2994 0.13341 -0.47438 -0.036797 1.399 0.54802 0.68619 0.65613 1.9793 0.19498 0 0 0 0 0 0 0 0 0 0 307.73 0.098137 0.051342 -0.010867 -0.069813
-1.398 -0.42457 1.1664 0.69572 0.3385 -1.4761 1.9543 0.18026 1.3606 0.48403 0.11458 2.179 -0.037517 0.54819 0.059217 0.15442 -0.095812 0.090856 0.12578 0.10402 0.071052 0.85062 0.088593 0.44184 0 0 0 0 0 0 0 0 0 0 307.01 0.096841 0.046966 -0.018063 -0.077265
-1.4148 -0.0066345 0.76341 0.66975 0.63005 -1.4656 2.0017 4.4017e-05 0.58279 0.44857 0.39696 2.1479 -0.016842 0.41794 -0.40303 -0.025969 0.29155 0.010583 0.040596 0.060079 1.3105 0.0017361 0.70115 0.00095826 0 0 0 0 0 0 0 0 0 0 307.67 0.095503 0.042507 -0.025189 -0.084174
-1.387 -1.6263 1.1817 0.80755 0.55166 -1.4178 1.9239 2.6447 1.3963 0.65213 0.30433 2.0101 0.027776 -1.6196 0.41825 0.1378 -0.078385 0.047793 0.016653 0.93291 1.8571 0.69467 0.060803 0.084979 0 0 0 0 0 0 0 0 0 0 306.76 0.094123 0.037974 -0.032215 -0.090493
-1.249 0.87037 0.41101 0.80719 0.67147 -1.3424 1.5601 0.75755 0.16893 0.65155 0.45088 1.802 0.13798 2.4966 -0.77065 -0.00035897 0.11981 0.075378 0.89393 2.192 5.14 0.0090612 0.11165 0.28151 0 0 0 0 0 0 0 0 0 0 307.44 0.092701 0.033375 -0.039114 -0.096177
-1.1904 -1.9713 0.67685 1.0462 0.44651 -1.1468 1.417 3.886 0.45813 1.0946 0.19937 1.3152 0.05867 -2.8417 0.26584 0.23906 -0.22497 0.19558 0.1281 2.8634 0.80535 1.8895 0.45709 2.4722 0 0 0 0 0 0 0 0 0 0 306.71 0.091239 0.028716 -0.045859 -0.10119
-1.105 -0.062535 0.5536 0.97036 0.86203 -0.98977 1.2211 0.0039107 0.30647 0.94159 0.7431 0.97965 0.085352 1.9088 -0.12326 -0.075887 0.41553 0.15704 0.30866 1.2795 0.084428 0.095122 1.4415 1.5333 0 0 0 0 0 0 0 0 0 0 307.1 0.089737 0.024008 -0.052422 -0.10549
-1.1165 -0.60988 0.30825 1.0095 0.85507 -0.96074 1.2465 0.37195 0.095019 1.0191 0.73114 0.92302 -0.011426 -0.54734 -0.24535 0.039133 -0.0069696 0.029033 0.026039 0.10797 0.44001 0.093778 0.0013937 0.016626 0 0 0 0 0 0 0 0 0 0 307.13 0.088196 0.019257 -0.058779 -0.10905
-1.23 -0.18675 0.31138 0.92682 0.90326 -0.99525 1.5128 0.034875 0.096954 0.859 0.81588 0.99053 -0.1135 0.42313 0.003124 -0.082671 0.048198 -0.034512 0.84189 0.061601 0.0090809 0.1188 0.015453 0.17788 0 0 0 0 0 0 0 0 0 0 307.35 0.086615 0.014472 -0.064904 -0.11184
-1.1763 -0.84705 0.078989 0.92369 1.0509 -0.94595 1.3837 0.71749 0.0062392 0.8532 1.1045 0.89483 0.053656 -0.6603 -0.23239 -0.0031319 0.14767 0.049301 0.1029 0.15659 0.38908 0.0064597 0.17286 0.092772 0 0 0 0 0 0 0 0 0 0 307.59 0.084997 0.0096623 -0.070772 -0.11385
-1.1502 -0.80739 0.42295 0.96333 0.90221 -0.94073 1.3229 0.65188 0.17889 0.92801 0.81399 0.88497 0.026108 0.039659 0.34396 0.039646 -0.14872 0.005224 0.013618 0.00041161 1.2903 0.095465 0.2049 0.0059905 0 0 0 0 0 0 0 0 0 0 307.03 0.083342 0.0048354 -0.076362 -0.11507
-1.0346 -1.224 0.42202 0.93129 0.86272 -0.80244 1.0703 1.4983 0.1781 0.86729 0.74429 0.64391 0.11563 -0.41666 -0.00092699 -0.032048 -0.039489 0.13829 0.60823 0.062958 0.0068766 0.0054987 0.017587 1.1573 0 0 0 0 0 0 0 0 0 0 307.8 0.08165 7.0705e-18 -0.08165 -0.11547
-0.96938 -0.81165 0.02609 0.81037 0.92353 -0.7952 0.93969 0.65878 0.00068067 0.6567 0.85291 0.63234 0.065182 0.41239 -0.39593 -0.12091 0.060807 0.007241 0.16497 0.058475 1.2613 0.30144 0.026004 0.0035902 0 0 0 0 0 0 0 0 0 0 307.37 0.079922 -0.0048354 -0.086615 -0.11507
-0.9768 0.0040614 0.17422 0.80549 0.98448 -0.78146 0.95414 1.6495e-05 0.030352 0.64881 0.96921 0.61069 -0.0074249 0.81571 0.14813 -0.0048857 0.060954 0.013732 0.017351 0.23186 0.28946 0.0050411 0.026143 1.3407e-05 0 0 0 0 0 0 0 0 0 0 307.42 0.078159 -0.0096623 -0.091239 -0.11385
-1.006 -0.94299 -0.23501 1.1474 1.318 -0.74509 1.0119 0.88922 0.05523 1.3166 1.7372 0.55517 -0.029152 -0.94705 -0.40923 0.34193 0.33353 0.03637 0.085663 0.32052 1.3542 3.703 0.92229 0.037065 0 0 0 0 0 0 0 0 0 0 307.91 0.076362 -0.014472 -0.095503 -0.11184
-1.0515 -0.61137 0.1002 0.89017 1.1292 -0.69527 1.1056 0.37378 0.01004 0.7924 1.2752 0.4834 -0.045506 0.33161 0.33521 -0.25724 -0.18878 0.049828 0.17126 0.037561 1.2304 1.6322 0.32494 0.095575 0 0 0 0 0 0 0 0 0 0 306.66 0.074531 -0.019257 -0.09939 -0.10905
-0.97589 -0.88058 -0.27552 0.93828 1.181 -0.67632 0.95237 0.77542 0.075913 0.88038 1.3947 0.4574 0.075565 -0.26921 -0.37573 0.048114 0.051717 0.018951 0.23336 0.02666 1.1266 0.12547 0.018123 0.0017273 0 0 0 0 0 0 0 0 0 0 306.75 0.072668 -0.024008 -0.10288 -0.10549
-0.9492 -0.23123 -0.15481 0.835 1.3329 -0.62819 0.90098 0.053466 0.023965 0.69722 1.7767 0.39462 0.026694 0.64935 0.12072 -0.10329 0.15197 0.048129 0.014649 0.14642 0.20641 0.20689 0.1835 0.086687 0 0 0 0 0 0 0 0 0 0 306.5 0.070772 -0.028716 -0.10597 -0.10119
-0.85821 -0.71335 -0.37084 1.0357 1.4401 -0.5881 0.73652 0.50886 0.13752 1.0728 2.074 0.34586 0.090995 -0.48212 -0.21603 0.20075 0.10719 0.040089 0.35686 0.083996 0.32927 1.3687 0.088313 0.050513 0 0 0 0 0 0 0 0 0 0 306.87 0.068846 -0.033375 -0.10864 -0.096177
-0.47654 0.26054 -0.29883 0.91243 1.3659 -0.36521 0.22709 0.067881 0.089298 0.83253 1.8657 0.13338 0.38166 0.97388 0.072008 -0.12331 -0.074221 0.22289 7.5662 0.33123 0.093397 0.31569 0.054935 3.2723 0 0 0 0 0 0 0 0 0 0 306.91 0.06689 -0.037974 -0.11089 -0.090493
-0.70652 -1.7602 -0.3775 0.83136 1.0722 -0.31127 0.49918 3.0984 0.14251 0.69116 1.1496 0.096886 -0.22998 -2.0208 -0.078675 -0.081073 -0.29372 0.053943 3.1699 1.4503 0.023856 0.11299 0.77007 0.1189 0 0 0 0 0 0 0 0 0 0 307.53 0.064904 -0.042507 -0.11269 -0.084174
-0.76104 1.1148 -0.73015 0.70771 1.6592 -0.39643 0.57919 1.2428 0.53312 0.50085 2.7531 0.15716 -0.054519 2.875 -0.35264 -0.12365 0.58706 -0.085163 0.23098 2.9085 0.98194 0.31774 2.9009 0.74083 0 0 0 0 0 0 0 0 0 0 307.24 0.062889 -0.046966 -0.11405 -0.077265
-0.7281 -1.6329 -0.48562 0.81473 1.2132 -0.36018 0.53013 2.6665 0.23583 0.66378 1.4718 0.12973 0.032941 -2.7477 0.24453 0.10702 -0.44606 0.036246 0.027994 2.6776 0.69279 0.44757 1.7527 0.036651 0 0 0 0 0 0 0 0 0 0 307.18 0.060848 -0.051342 -0.11496 -0.069813
-0.79829 -0.72981 -0.35515 0.85793 1.2536 -0.34495 0.63727 0.53263 0.12613 0.73605 1.5716 0.11899 -0.070189 0.90312 0.13047 0.043208 0.040447 0.015231 0.35604 0.28459 0.23437 0.10759 0.010323 8.6929e-05 0 0 0 0 0 0 0 0 0 0 307.17 0.058779 -0.055628 -0.11541 -0.061872
-0.76955 0.85101 -0.57952 0.51123 1.1874 -0.41825 0.59221 0.72422 0.33585 0.26136 1.4099 0.17493 0.028736 1.5808 -0.22438 -0.3467 -0.066216 -0.0733 0.01854 0.87656 0.35917 3.0822 0.044491 0.57442 0 0 0 0 0 0 0 0 0 0 307.21 0.056685 -0.059817 -0.11541 -0.053497
-0.80758 -1.4416 -0.18698 0.59822 0.69273 -0.36157 0.65218 2.0783 0.03496 0.35786 0.47988 0.13073 -0.038021 -2.2926 0.39255 0.086982 -0.49468 0.05668 0.12844 1.8656 1.6493 0.31577 2.1502 0.13582 0 0 0 0 0 0 0 0 0 0 306.77 0.054565 -0.0639 -0.11496 -0.044746
-0.73243 1.0213 -0.25284 0.29842 0.71589 -0.43154 0.53645 1.043 0.063929 0.089056 0.5125 0.18622 0.075148 2.4629 -0.065865 -0.29979 0.023161 -0.069963 0.23038 2.133 0.013304 2.2648 0.002596 0.53143 0 0 0 0 0 0 0 0 0 0 306.37 0.052422 -0.067872 -0.11405 -0.035682
-0.82717 -1.2096 -0.37657 0.54444 0.5031 -0.37222 0.68421 1.4632 0.1418 0.29641 0.25311 0.13855 -0.09474 -2.2309 -0.12372 0.24601 -0.21279 0.059315 0.60616 1.7667 0.085261 1.9931 0.4101 0.15317 0 0 0 0 0 0 0 0 0 0 306.77 0.050256 -0.071724 -0.11269 -0.026368
-0.76184 0.15589 -0.38516 0.49532 0.78368 -0.34296 0.5804 0.0243 0.14835 0.24535 0.61415 0.11762 0.065331 1.3655 -0.0085929 -0.049113 0.28057 0.02926 0.16586 0.65331 0.0035426 0.027339 0.64831 0.017137 0 0 0 0 0 0 0 0 0 0 306.8 0.048068 -0.075451 -0.11089 -0.016868
-0.77251 -0.77527 -0.60201 0.57432 0.79743 -0.33386 0.59677 0.60105 0.36242 0.32985 0.63589 0.11146 -0.010669 -0.93116 -0.21685 0.079001 0.013754 0.0091028 0.02426 0.30991 0.33215 0.26965 0.00054701 0.0019169 0 0 0 0 0 0 0 0 0 0 307.48 0.045859 -0.079045 -0.10864 -0.0072504
-0.74281 0.93151 -0.30542 0.5179 0.82324 -0.35874 0.55177 0.8677 0.093281 0.26823 0.67772 0.12869 0.029695 1.7068 0.29659 -0.05642 0.025811 -0.02488 0.020524 1.0223 0.98267 0.041777 0.0034478 0.11444 0 0 0 0 0 0 0 0 0 0 307.24 0.043629 -0.0825 -0.10597 0.0024182
-0.61512 0.72698 -0.48487 0.5513 0.55014 -0.33526 0.37837 0.5285 0.2351 0.30394 0.30265 0.1124 0.12769 -0.20453 -0.17945 0.0334 -0.27311 0.023478 0.7556 0.015585 0.21357 0.075953 0.66769 0.0065274 0 0 0 0 0 0 0 0 0 0 307.47 0.041381 -0.085811 -0.10288 0.01207
-0.72917 -0.53763 -0.18166 0.53842 0.3592 -0.30413 0.53169 0.28904 0.033 0.2899 0.12902 0.092493 -0.11405 -1.2646 0.30321 -0.012885 -0.19094 0.031132 0.84944 0.56983 1.0232 0.00079828 0.3322 0.021647 0 0 0 0 0 0 0 0 0 0 306.88 0.039114 -0.088971 -0.09939 0.021637
-0.68023 -0.036311 -0.46808 0.17264 0.49954 -0.29022 0.46271 0.0013185 0.2191 0.029804 0.24954 0.084226 0.048945 0.50131 -0.28642 -0.36578 0.14034 0.01391 0.081722 0.086827 0.6221 3.4506 0.15547 4.5039e-06 0 0 0 0 0 0 0 0 0 0 306.38 0.03683 -0.091975 -0.095503 0.031052
-0.59846 -0.27568 -0.14558 0.1484 0.35063 -0.26457 0.35816 0.075999 0.021193 0.022023 0.12294 0.069999 0.081763 -0.23937 0.3225 -0.024238 -0.14891 0.025644 0.27983 0.021184 1.1458 0.0010509 0.20542 0.0099131 0 0 0 0 0 0 0 0 0 0 306.84 0.03453 -0.094818 -0.091239 0.04025
-0.50031 -0.58355 -0.54421 0.18995 0.38563 -0.22153 0.25031 0.34053 0.29616 0.036081 0.14871 0.049075 0.098152 -0.30787 -0.39863 0.04155 0.035006 0.043046 0.42302 0.034693 1.2799 0.10185 0.0073374 0.062688 0 0 0 0 0 0 0 0 0 0 308 0.032215 -0.097495 -0.086615 0.049165
-0.33949 1.175 -0.67943 0.22554 0.42684 -0.14622 0.11525 1.3807 0.46163 0.050869 0.18219 0.021381 0.16082 1.7586 -0.13523 0.035591 0.041206 0.075307 1.2425 1.0856 0.107 0.082542 0.01078 0.28086 0 0 0 0 0 0 0 0 0 0 307.91 0.029886 -0.1 -0.08165 0.057735
-0.2553 -0.71155 -0.15064 0.028907 -0.27839 -0.012511 0.065177 0.5063 0.022692 0.00083559 0.077503 0.00015653 0.084194 -1.8866 0.52879 -0.19663 -0.70523 0.13371 0.29921 1.2646 2.8909 0.9095 4.3401 1.0735 0 0 0 0 0 0 0 0 0 0 307.95 0.027543 -0.10233 -0.076362 0.0659
-0.031006 1.7934 -0.35406 -0.11291 -0.037578 -0.051702 0.00096136 3.2162 0.12536 0.012748 0.0014121 0.0026731 0.22429 2.5049 -0.20342 -0.14181 0.24082 -0.039191 2.5118 2.2066 0.28658 0.43654 0.4743 0.21373 0 0 0 0 0 0 0 0 0 0 307.11 0.025189 -0.10448 -0.070772 0.073603
-0.087856 -1.3767 0.11413 0.14945 0.38647 0.053176 0.0077187 1.8954 0.013025 0.022337 0.14936 0.0028277 -0.056851 -3.1701 0.46819 0.26236 0.42404 0.10488 0.24788 3.5622 2.2959 2.2474 1.502 0.61816 0 0 0 0 0 0 0 0 0 0 307.16 0.022824 -0.10645 -0.064904 0.08079
-0.064149 1.0069 -0.27141 -0.098853 0.75627 0.012638 0.0041151 1.0139 0.073666 0.009772 0.57194 0.00015973 0.023707 2.3837 -0.38554 -0.24831 0.3698 -0.040537 0.0097827 1.9977 1.1911 1.5124 1.1377 0.22466 0 0 0 0 0 0 0 0 0 0 306.55 0.020448 -0.10823 -0.058779 0.08741
0.056366 -0.56967 -0.0097419 -0.022867 0.42442 0.098335 0.0031772 0.32453 9.4904e-05 0.00052289 0.18013 0.0096698 0.12052 -1.5766 0.26167 0.075987 -0.33185 0.085697 0.66597 0.88418 0.78267 0.25318 0.97861 0.3844 0 0 0 0 0 0 0 0 0 0 306.54 0.018063 -0.10982 -0.052422 0.093417
0.020435 0.42041 -0.24659 -0.16553 0.36331 0.0977 0.00041759 0.17675 0.060808 0.027399 0.13199 0.0095452 -0.035931 0.99009 -0.23685 -0.14266 -0.061111 -0.00063561 0.11758 0.34241 0.40627 0.44254 0.038404 0.01643 0 0 0 0 0 0 0 0 0 0 306.78 0.015671 -0.11122 -0.045859 0.098769
0.12855 0.1741 0.16699 -0.066866 0.48185 0.24053 0.016525 0.030311 0.027887 0.004471 0.23218 0.057855 0.10811 -0.24631 0.41359 0.09866 0.11854 0.14283 0.52446 0.022402 1.8185 0.38979 0.10919 1.2436 0 0 0 0 0 0 0 0 0 0 307.12 0.013272 -0.11242 -0.039114 0.10343
0.26081 1.859 -0.084941 -0.21123 0.47271 0.18015 0.068021 3.4559 0.007215 0.044619 0.22345 0.032456 0.13226 1.6849 -0.25194 -0.14437 -0.0091483 -0.060377 0.81554 0.99621 0.4671 0.45477 0.0019111 0.41721 0 0 0 0 0 0 0 0 0 0 306.97 0.010867 -0.11342 -0.032215 0.10736
0.13062 -0.50999 0.349 -0.053979 0.17993 0.28831 0.017062 0.26009 0.1218 0.0029138 0.032377 0.083124 -0.13019 -2.369 0.43394 0.15725 -0.29277 0.10816 1.084 1.9916 1.99 0.87881 0.76518 0.66366 0 0 0 0 0 0 0 0 0 0 306.94 0.0084568 -0.11423 -0.025189 0.11054
0.15598 2.0718 -0.065457 -0.18305 0.83806 0.2882 0.02433 4.2925 0.0042846 0.033507 0.70235 0.083061 0.025361 2.5818 -0.41446 -0.12907 0.65813 -0.00010939 0.012357 2.3445 1.3916 0.35119 3.6536 0.015282 0 0 0 0 0 0 0 0 0 0 306.29 0.0060432 -0.11484 -0.018063 0.11295
0.22425 0.0074232 0.3498 -0.02641 0.62779 0.44245 0.050287 5.5104e-05 0.12236 0.00069747 0.39412 0.19577 0.068266 -2.0644 0.41526 0.15664 -0.21027 0.15425 0.18404 1.5135 1.8322 0.87266 0.40072 1.4741 0 0 0 0 0 0 0 0 0 0 306.22 0.003627 -0.11524 -0.010867 0.11456
0.24235 0.80486 -0.14803 -0.13032 0.64749 0.46108 0.058735 0.64779 0.021912 0.016983 0.41924 0.21259 0.018107 0.79743 -0.49783 -0.10391 0.019699 0.018624 0.0032972 0.22152 2.0569 0.20992 0.0016654 0.0014999 0 0 0 0 0 0 0 0 0 0 306.88 0.0012092 -0.11544 -0.003627 0.11537
0.32603 0.028841 0.13657 -0.32187 0.95681 0.49762 0.1063 0.00083178 0.018652 0.1036 0.91549 0.24763 0.083679 -0.77602 0.2846 -0.19155 0.30932 0.036545 0.29505 0.21575 0.91143 0.85841 0.79108 0.03765 0 0 0 0 0 0 0 0 0 0 307.23 -0.0012092 -0.11544 0.003627 0.11537
0.29709 -0.73831 0.10653 -0.13054 0.53424 0.60399 0.088264 0.54511 0.011348 0.017042 0.28541 0.36481 -0.028941 -0.76715 -0.030045 0.19132 -0.42258 0.10637 0.084747 0.21089 3.5732e-05 1.2533 1.5752 0.63866 0 0 0 0 0 0 0 0 0 0 307.04 -0.003627 -0.11524 0.010867 0.11456
0.25735 0.67654 0.25511 -0.23601 0.61811 0.62078 0.066229 0.4577 0.065079 0.055703 0.38206 0.38537 -0.039743 1.4149 0.14858 -0.10547 0.083874 0.016789 0.13774 0.70158 0.29094 0.21764 0.05237 0.00052123 0 0 0 0 0 0 0 0 0 0 306.76 -0.0060432 -0.11484 0.018063 0.11295
0.26608 0.81637 -0.088755 -0.33431 0.62371 0.52145 0.070797 0.66646 0.0078774 0.11176 0.38902 0.27191 0.0087284 0.13983 -0.34386 -0.098295 0.0055996 -0.099335 0.00014538 0.0063719 0.9295 0.18333 2.5404e-07 0.96733 0 0 0 0 0 0 0 0 0 0 306.14 -0.0084568 -0.11423 0.025189 0.11054
0.19609 -0.74657 0.24106 -0.16319 0.56348 0.57628 0.038453 0.55736 0.058109 0.026629 0.31751 0.3321 -0.069983 -1.5629 0.32981 0.17112 -0.060228 0.054834 0.35421 0.86897 1.1941 1.0233 0.037397 0.12428 0 0 0 0 0 0 0 0 0 0 307.17 -0.010867 -0.11342 0.032215 0.10736
0.24954 1.8233 0.025628 -0.46402 0.80267 0.50481 0.062271 3.3244 0.00065679 0.21532 0.64428 0.25483 0.053447 2.5699 -0.21543 -0.30084 0.23919 -0.071476 0.1019 2.3228 0.32717 2.2817 0.46776 0.55071 0 0 0 0 0 0 0 0 0 0 306.65 -0.013272 -0.11242 0.039114 0.10343
0.274 -0.44729 0.025243 -0.096508 0.67556 0.55809 0.075076 0.20007 0.0006372 0.0093139 0.45638 0.31146 0.024458 -2.2706 -0.00038511 0.36751 -0.12712 0.053284 0.010913 1.83 0.0071537 4.2479 0.15161 0.11499 0 0 0 0 0 0 0 0 0 0 306.68 -0.015671 -0.11122 0.045859 0.098769
0.33441 1.2379 -0.066206 -0.31616 0.82511 0.56197 0.11183 1.5324 0.0043832 0.099957 0.6808 0.31581 0.060414 1.6852 -0.091449 -0.21965 0.14955 0.0038846 0.13752 0.99653 0.037424 1.1592 0.17747 0.007922 0 0 0 0 0 0 0 0 0 0 306.26 -0.018063 -0.10982 0.052422 0.093417
0.36072 -0.074802 -0.0047737 -0.095154 0.26704 0.66114 0.13012 0.0055953 2.2789e-05 0.0090544 0.071311 0.4371 0.026311 -1.3127 0.061432 0.221 -0.55806 0.099163 0.013971 0.6138 0.074703 1.6336 2.7293 0.54273 0 0 0 0 0 0 0 0 0 0 307.44 -0.020448 -0.10823 0.058779 0.08741
0.30794 0.0068624 0.10114 -0.23402 0.53998 0.70924 0.094825 4.7092e-05 0.01023 0.054767 0.29158 0.50303 -0.052788 0.081664 0.10592 -0.13887 0.27294 0.048106 0.21881 0.0020478 0.16739 0.41601 0.6128 0.086573 0 0 0 0 0 0 0 0 0 0 307.49 -0.022824 -0.10645 0.064904 0.08079
0.30768 0.46156 -0.60505 -0.30072 0.59907 0.53558 0.094669 0.21304 0.36609 0.090431 0.35888 0.28685 -0.00025291 0.4547 -0.70619 -0.066694 0.059084 -0.17366 0.0061767 0.071267 4.2864 0.067234 0.024401 2.6493 0 0 0 0 0 0 0 0 0 0 307.61 -0.025189 -0.10448 0.070772 0.073603
0.34467 -0.56589 -0.25812 -0.20292 0.82855 0.66517 0.1188 0.32023 0.066627 0.041176 0.68649 0.44246 0.036983 -1.0275 0.34693 0.0978 0.22948 0.12959 0.038911 0.37691 1.311 0.38408 0.42967 1.0008 0 0 0 0 0 0 0 0 0 0 307.42 -0.027543 -0.10233 0.076362 0.0659
0.53363 1.3698 -0.63329 -0.17453 0.92306 0.61591 0.28476 1.8763 0.40105 0.030461 0.85205 0.37934 0.18896 1.9357 -0.37516 0.028387 0.094514 -0.049266 1.7506 1.3159 1.1229 0.061905 0.067611 0.30209 0 0 0 0 0 0 0 0 0 0 307.32 -0.029886 -0.1 0.08165 0.057735
0.38802 -1.0879 -0.0074791 -0.33933 0.62117 0.69396 0.15056 1.1836 5.5937e-05 0.11515 0.38586 0.48158 -0.14561 -2.4577 0.62581 -0.1648 -0.30189 0.078051 1.3349 2.1432 3.9858 0.61399 0.81265 0.30663 0 0 0 0 0 0 0 0 0 0 307.39 -0.032215 -0.097495 0.086615 0.049165
0.4513 1.1389 -0.51289 -0.4478 0.81962 0.61478 0.20367 1.2972 0.26305 0.20053 0.67178 0.37796 0.06328 2.2269 -0.50541 -0.10847 0.19845 -0.079174 0.15372 1.743 2.1239 0.23283 0.31872 0.65418 0 0 0 0 0 0 0 0 0 0 306.96 -0.03453 -0.094818 0.091239 0.04025
0.58298 -0.4225 -0.087831 -0.13553 0.56668 0.75324 0.33986 0.17851 0.0077142 0.018367 0.32113 0.56738 0.13168 -1.5614 0.42506 0.31227 -0.25294 0.13846 0.80777 0.86731 1.9142 3.1183 0.57463 1.1605 0 0 0 0 0 0 0 0 0 0 306.67 -0.03683 -0.091975 0.095503 0.031052
0.64976 2.0793 -0.32186 -0.58463 0.72908 0.61827 0.42219 4.3234 0.10359 0.34179 0.53156 0.38226 0.066781 2.5018 -0.23403 -0.4491 0.1624 -0.13497 0.17472 2.2011 0.39536 5.3029 0.21063 1.6702 0 0 0 0 0 0 0 0 0 0 306.11 -0.039114 -0.088971 0.09939 0.021637
0.62916 -1.0838 -0.1902 -0.39154 0.59346 0.72518 0.39585 1.1747 0.036177 0.1533 0.3522 0.52589 -0.020595 -3.1631 0.13166 0.19309 -0.13562 0.10691 0.052575 3.5465 0.23788 1.2745 0.17164 0.64616 0 0 0 0 0 0 0 0 0 0 307.17 -0.041381 -0.085811 0.10288 0.01207
0.63383 1.76 -0.66692 -0.72706 0.38527 0.62868 0.40174 3.0976 0.44478 0.52862 0.14843 0.39523 0.0046647 2.8438 -0.47672 -0.33552 -0.20819 -0.096506 0.0017776 2.8456 1.8762 2.876 0.39303 0.91972 0 0 0 0 0 0 0 0 0 0 307 -0.043629 -0.0825 0.10597 0.0024182
0.69052 -0.61539 -0.36291 -0.42252 0.25423 0.76164 0.47682 0.37871 0.1317 0.17853 0.064632 0.5801 0.056697 -2.3754 0.30401 0.30454 -0.13104 0.13297 0.11785 2.0024 1.0281 2.974 0.1607 1.0602 0 0 0 0 0 0 0 0 0 0 308.04 -0.045859 -0.079045 0.10864 -0.0072504
0.71466 0.15432 -0.26335 -0.58981 0.37796 0.83654 0.51074 0.023814 0.069355 0.34788 0.14285 0.69979 0.024139 0.76971 0.099553 -0.16729 0.12373 0.074893 0.010426 0.20628 0.15187 0.635 0.11946 0.27706 0 0 0 0 0 0 0 0 0 0 307.7 -0.048068 -0.075451 0.11089 -0.016868
0.58864 1.112 -0.21217 -0.77886 0.61283 0.74828 0.3465 1.2366 0.045014 0.60662 0.37556 0.55992 -0.12602 0.95769 0.051189 -0.18904 0.23487 -0.08826 1.0207 0.32024 0.058586 0.83375 0.45061 0.78776 0 0 0 0 0 0 0 0 0 0 307.62 -0.050256 -0.071724 0.11269 -0.026368
0.61218 -1.2711 -0.14961 -0.60994 0.11272 0.84456 0.37477 1.6158 0.022382 0.37203 0.012706 0.71328 0.02354 -2.3831 0.062558 0.16892 -0.50011 0.096284 0.0095388 2.0154 0.076594 0.99954 2.1971 0.50659 0 0 0 0 0 0 0 0 0 0 307.4 -0.052422 -0.067872 0.11405 -0.035682
0.58485 1.3089 -0.17225 -0.72587 0.61546 0.73665 0.34205 1.7133 0.02967 0.52689 0.37879 0.54266 -0.027336 2.5801 -0.022643 -0.11593 0.50274 -0.10791 0.077967 2.3413 0.00027627 0.2729 2.1204 1.119 0 0 0 0 0 0 0 0 0 0 306.77 -0.054565 -0.0639 0.11496 -0.044746
0.70149 -0.30594 -0.34613 -0.62622 0.13763 0.70896 0.49208 0.093597 0.11981 0.39215 0.018941 0.50263 0.11664 -1.6149 -0.17388 0.099652 -0.47784 -0.027687 0.61992 0.92746 0.19815 0.39644 2.0079 0.13149 0 0 0 0 0 0 0 0 0 0 307.52 -0.056685 -0.059817 0.11541 -0.053497
0.70089 0.95568 -0.2661 -0.77007 0.43857 0.67277 0.49124 0.91331 0.070808 0.593 0.19234 0.45262 -0.00059874 1.2616 0.080037 -0.14385 0.30094 -0.036191 0.006586 0.55731 0.10898 0.45103 0.74799 0.19037 0 0 0 0 0 0 0 0 0 0 307.3 -0.058779 -0.055628 0.11541 -0.061872
0.74664 -0.5417 -0.60205 -0.68566 0.4047 0.66999 0.55747 0.29344 0.36246 0.47013 0.16378 0.44889 0.045752 -1.4974 -0.33595 0.084402 -0.03387 -0.002782 0.068757 0.79784 0.88352 0.30046 0.013491 0.021544 0 0 0 0 0 0 0 0 0 0 307.6 -0.060848 -0.051342 0.11496 -0.069813
0.78493 0.34048 -0.41604 -0.74681 0.44101 0.70683 0.61611 0.11592 0.17309 0.55773 0.19449 0.49961 0.03829 0.88217 0.18601 -0.06115 0.036307 0.036837 0.042825 0.27146 0.42727 0.052747 0.0080052 0.038641 0 0 0 0 0 0 0 0 0 0 307.44 -0.062889 -0.046966 0.11405 -0.077265
0.77582 0.20229 -0.88254 -0.55386 0.36748 0.73023 0.60189 0.04092 0.77888 0.30676 0.13504 0.53324 -0.0091109 -0.13819 -0.4665 0.19295 -0.073524 0.023402 0.020797 0.0072953 1.7917 1.2729 0.053982 0.0064227 0 0 0 0 0 0 0 0 0 0 307.19 -0.064904 -0.042507 0.11269 -0.084174
0.72271 -0.48828 -0.56724 -0.55151 0.026428 0.78943 0.5223 0.23841 0.32176 0.30416 0.00069841 0.6232 -0.053113 -0.69056 0.3153 0.0023558 -0.34105 0.059196 0.22107 0.17115 1.0992 0.012034 1.0327 0.15236 0 0 0 0 0 0 0 0 0 0 307.82 -0.06689 -0.037974 0.11089 -0.090493
0.68862 1.7289 -0.75262 -0.90837 0.20233 0.64099 0.4742 2.9893 0.56644 0.82513 0.040938 0.41086 -0.034087 2.2172 -0.18539 -0.35686 0.1759 -0.14844 0.1084 1.7279 0.23065 3.2758 0.2485 1.9856 0 0 0 0 0 0 0 0 0 0 306.95 -0.068846 -0.033375 0.10864 -0.096177
0.74513 -1.1191 -0.51145 -0.63509 -0.17359 0.82654 0.55522 1.2525 0.26158 0.40334 0.030133 0.68317 0.056515 -2.8481 0.24118 0.27328 -0.37592 0.18555 0.11693 2.8764 0.67587 2.4257 1.2508 2.2064 0 0 0 0 0 0 0 0 0 0 307.24 -0.070772 -0.028716 0.10597 -0.10119
0.77544 0.58329 -0.57195 -0.74141 0.12347 0.89216 0.6013 0.34023 0.32713 0.54968 0.015245 0.79596 0.030302 1.7024 -0.060505 -0.10632 0.29706 0.065623 0.021833 1.0171 0.0097965 0.22188 0.72844 0.19895 0 0 0 0 0 0 0 0 0 0 306.85 -0.072668 -0.024008 0.10288 -0.10549
0.90709 1.6819 -0.88189 -0.8845 0.35694 0.85351 0.82281 2.8287 0.77772 0.78234 0.12741 0.72847 0.13165 1.0986 -0.30993 -0.14309 0.23347 -0.038659 0.80742 0.42202 0.7405 0.44564 0.44512 0.20949 0 0 0 0 0 0 0 0 0 0 307.72 -0.074531 -0.019257 0.09939 -0.10905
1.0635 -0.44038 -0.65 -0.8889 0.014957 0.95774 1.131 0.19394 0.42249 0.79014 0.00022372 0.91726 0.15638 -2.1222 0.23189 -0.0043989 -0.34198 0.10423 1.1702 1.5992 0.63005 0.0054172 1.0383 0.60941 0 0 0 0 0 0 0 0 0 0 307.55 -0.076362 -0.014472 0.095503 -0.11184
0.95703 -0.30329 -1.238 -0.8345 -4.8746e-05 0.87442 0.91591 0.091983 1.5326 0.69639 2.3762e-09 0.76461 -0.10643 0.13709 -0.58798 0.054397 -0.015006 -0.083317 0.74853 0.0061146 2.9222 0.15039 0.0037064 0.71355 0 0 0 0 0 0 0 0 0 1 308.86 -0.078159 -0.0096623 0.091239 -0.11385
0.88239 -0.38169 -0.86428 -0.97796 -0.43631 0.9096 0.77861 0.14569 0.74697 0.95641 0.19036 0.82738 -0.074647 -0.078401 0.3737 -0.14346 -0.43626 0.035182 0.39654 0.0024879 1.5048 0.44827 1.6775 0.033206 0 0 0 0 0 0 0 0 0 0 308.24 -0.079922 -0.0048354 0.086615 -0.11507
0.94648 1.056 -1.1983 -1.0479 -0.51291 0.76094 0.89582 1.1151 1.4359 1.0981 0.26308 0.57904 0.064089 1.4377 -0.33401 -0.069961 -0.076605 -0.14866 0.15845 0.72447 0.87243 0.076593 0.058258 1.9909 0 0 0 0 0 0 0 0 0 0 308.14 -0.08165 -2.1212e-17 0.08165 -0.11547
0.94148 -1.0652 -0.60122 -1.0098 -0.59053 0.85731 0.88639 1.1347 0.36147 1.0197 0.34873 0.73498 -0.004996 -2.1212 0.59707 0.038136 -0.077621 0.096364 0.012934 1.5976 3.6431 0.090541 0.059705 0.50758 0 0 0 0 0 0 0 0 0 0 307.12 -0.083342 0.0048354 0.076362 -0.11507
1.0651 1.0564 -1.0552 -1.0113 -0.33493 0.76898 1.1345 1.1161 1.1133 1.0227 0.11218 0.59133 0.12363 2.1217 -0.45393 -0.0015095 0.25561 -0.088329 0.70422 1.5818 1.6904 0.0079285 0.53587 0.78881 0 0 0 0 0 0 0 0 0 0 307.24 -0.084997 0.0096623 0.070772 -0.11385
1.1859 0.06822 -0.48416 -0.92888 -0.75434 0.99531 1.4063 0.0046539 0.23441 0.86281 0.56902 0.99065 0.12074 -0.98822 0.57099 0.082421 -0.41941 0.22633 0.66873 0.34882 3.3455 0.28897 1.552 3.3811 0 0 0 0 0 0 0 0 0 0 306.98 -0.086615 0.014472 0.064904 -0.11184
1.1514 -0.08733 -1.0069 -0.84012 -0.66505 0.95899 1.3258 0.0076266 1.0139 0.70579 0.44229 0.91967 -0.03444 -0.15555 -0.52274 0.08876 0.089289 -0.03632 0.11013 0.0091644 2.2809 0.32653 0.059883 0.19135 0 0 0 0 0 0 0 0 0 0 307.59 -0.088196 0.019257 0.058779 -0.10905
1.2608 1.1569 -0.47196 -1.1295 -0.8448 1.0252 1.5896 1.3385 0.22274 1.2757 0.71369 1.051 0.10939 1.2443 0.53495 -0.28935 -0.17976 0.066179 0.5382 0.54202 2.9551 2.1 0.29551 0.20327 0 0 0 0 0 0 0 0 0 0 307.94 -0.089737 0.024008 0.052422 -0.10549
1.1918 -0.61434 -0.5311 -1.0715 -1.0799 1.1024 1.4204 0.37742 0.28207 1.1482 1.1662 1.2152 -0.068998 -1.7713 -0.059142 0.057928 -0.23511 0.077211 0.34558 1.1151 0.0089898 0.16538 0.49813 0.29862 0 0 0 0 0 0 0 0 0 0 307.88 -0.091239 0.028716 0.045859 -0.10119
1.202 1.2411 -0.49475 -1.2948 -0.82987 1.1165 1.4448 1.5404 0.24478 1.6766 0.68868 1.2467 0.010202 1.8555 0.036349 -0.22331 0.25004 0.014158 1.2953e-06 1.2089 0.038705 1.2017 0.51227 6.8632e-10 0 0 0 0 0 0 0 0 0 0 307.31 -0.092701 0.033375 0.039114 -0.096177
1.2152 -0.091237 -0.66711 -1.1706 -1.0697 1.1129 1.4767 0.0083241 0.44504 1.3703 1.1442 1.2386 0.013176 -1.3324 -0.17236 0.12425 -0.23982 -0.0036361 0.00043628 0.63227 0.19403 0.57926 0.51783 0.023772 0 0 0 0 0 0 0 0 0 0 307.11 -0.094123 0.037974 0.032215 -0.090493
1.1754 0.49677 -0.37239 -1.1954 -0.86082 1.1586 1.3816 0.24678 0.13867 1.4289 0.741 1.3422 -0.039784 0.58801 0.29472 -0.024755 0.20887 0.04565 0.13797 0.11985 0.97139 0.0012375 0.35414 0.074498 0 0 0 0 0 0 0 0 0 0 307.78 -0.095503 0.042507 0.025189 -0.084174
1.1223 1.2403 -0.54516 -1.4008 -0.87225 1.0439 1.2596 1.5383 0.2972 1.9623 0.76083 1.0896 -0.053085 0.74352 -0.17277 -0.20548 -0.011439 -0.1147 0.22088 0.19238 0.19515 1.0019 0.002543 1.2469 0 0 0 0 0 0 0 0 0 0 307.8 -0.096841 0.046966 0.018063 -0.077265
1.1071 -1.1092 -0.43488 -1.0382 -1.0304 1.1057 1.2256 1.2303 0.18912 1.078 1.0617 1.2227 -0.015258 -2.3495 0.11028 0.36259 -0.15813 0.06188 0.036006 1.959 0.17847 4.1401 0.23064 0.17106 0 0 0 0 0 0 0 0 0 0 307.24 -0.098137 0.051342 0.010867 -0.069813
1.1735 1.276 -0.53433 -1.3538 -0.61485 0.98794 1.3771 1.6281 0.28551 1.8328 0.37804 0.97603 0.066433 2.3851 -0.099446 -0.31555 0.41554 -0.11779 0.17258 2.0002 0.047468 2.5254 1.4416 1.3076 0 0 0 0 0 0 0 0 0 0 307.19 -0.09939 0.055628 0.003627 -0.061872
1.2647 -0.74841 -0.66609 -1.1632 -1.0293 1.0555 1.5996 0.56011 0.44368 1.353 1.0595 1.1141 0.091248 -2.0244 -0.13176 0.1906 -0.41448 0.06755 0.3591 1.4555 0.1002 1.2447 1.5163 0.21412 0 0 0 0 0 0 0 0 0 0 307.34 -0.1006 0.059817 -0.003627 -0.053497
1.1757 0.91547 -0.55645 -1.3026 -0.65808 1.0141 1.3824 0.83808 0.30964 1.6967 0.43306 1.0284 -0.088999 1.6639 0.10964 -0.13938 0.37125 -0.041397 0.54174 0.97142 0.17683 0.41952 1.1468 0.23177 0 0 0 0 0 0 0 0 0 0 307.31 -0.10176 0.0639 -0.010867 -0.044746
1.1637 0.46675 -0.92528 -1.2479 -0.77009 0.86949 1.3541 0.21786 0.85615 1.5573 0.59303 0.75601 -0.012077 -0.44871 -0.36883 0.054659 -0.11201 -0.14461 0.027617 0.072882 1.0823 0.15147 0.1191 1.8931 0 0 0 0 0 0 0 0 0 0 306.85 -0.10288 0.067872 -0.018063 -0.035682
1.1991 -0.62065 -0.74142 -1.1619 -0.54547 1.0466 1.4378 0.38521 0.54971 1.3499 0.29754 1.0955 0.035422 -1.0874 0.18386 0.086045 0.22462 0.17715 0.03448 0.42193 0.41874 0.31016 0.41118 1.9954 0 0 0 0 0 0 0 0 0 0 308.09 -0.10396 0.071724 -0.025189 -0.026368
1.2545 1.7329 -1.1295 -1.127 -0.77637 1.0065 1.5738 3.003 1.2757 1.2702 0.60275 1.0129 0.055415 2.3536 -0.38803 0.034832 -0.2309 -0.040189 0.11142 1.9474 1.2077 0.080228 0.48089 0.2218 0 0 0 0 0 0 0 0 0 0 307.62 -0.10499 0.075451 -0.032215 -0.016868
1.2643 -0.70513 -0.80552 -0.97628 -0.82136 1.1697 1.5986 0.49721 0.64886 0.95312 0.67463 1.3681 0.0098423 -2.438 0.32394 0.15076 -0.044989 0.16321 1.4484e-05 2.1091 1.1552 0.81495 0.022121 1.6686 0 0 0 0 0 0 0 0 0 0 308.53 -0.10597 0.079045 -0.039114 -0.0072504
1.1092 0.91563 -1.2254 -1.1715 -1.071 1.0308 1.2303 0.83838 1.5016 1.3725 1.1469 1.0625 -0.15517 1.6208 -0.41989 -0.19526 -0.2496 -0.13887 1.5037 0.92157 1.431 0.89551 0.55987 1.7587 0 0 0 0 0 0 0 0 0 0 308.06 -0.10691 0.0825 -0.045859 0.0024182
1.0447 -0.45277 -0.81038 -1.1212 -0.78821 1.0781 1.0914 0.205 0.65671 1.257 0.62128 1.1622 -0.064454 -1.3684 0.41503 0.050379 0.28274 0.047266 0.30713 0.66677 1.8304 0.1342 0.65861 0.082342 0 0 0 0 0 0 0 0 0 0 308.07 -0.1078 0.085811 -0.052422 0.01207
1.0157 0.48483 -1.0849 -1.1954 -0.51378 0.93758 1.0317 0.23506 1.1771 1.4289 0.26397 0.87906 -0.028993 0.93759 -0.27457 -0.074225 0.27444 -0.14048 0.084974 0.30687 0.56635 0.089724 0.61969 1.7958 0 0 0 0 0 0 0 0 0 0 308.33 -0.10864 0.088971 -0.058779 0.021637
0.9683 -1.1171 -0.74931 -1.037 -1.1022 1.0348 0.93761 1.2479 0.56147 1.0753 1.2148 1.0708 -0.047419 -1.6019 0.33564 0.15843 -0.58839 0.097228 0.18318 0.91272 1.2332 0.8906 3.0309 0.5183 0 0 0 0 0 0 0 0 0 0 307.85 -0.10944 0.091975 -0.064904 0.031052
1.0257 1.3037 -1.1199 -1.3512 -0.54829 0.89379 1.052 1.6995 1.2543 1.8257 0.30062 0.79886 0.057387 2.4208 -0.37063 -0.31423 0.55388 -0.14102 0.12139 2.0605 1.0938 2.5031 2.5792 1.8084 0 0 0 0 0 0 0 0 0 0 307.54 -0.11019 0.094818 -0.070772 0.04025
1.0746 -0.52169 -0.76081 -1.0808 -0.94775 1.0274 1.1549 0.27216 0.57883 1.1681 0.89824 1.0555 0.048953 -1.8253 0.35914 0.27042 -0.39946 0.13357 0.081758 1.1841 1.3978 2.3784 1.4098 1.0709 0 0 0 0 0 0 0 0 0 0 306.97 -0.11089 0.097495 -0.076362 0.049165
1.3508 2.0389 -0.49923 -1.2401 -0.94347 0.9416 1.8247 4.1572 0.24923 1.5378 0.89013 0.88661 0.27617 2.5606 0.26158 -0.1593 0.0042865 -0.085759 3.8775 2.306 0.78219 0.56878 1.8934e-05 0.74975 0 0 0 0 0 0 0 0 0 0 306.89 -0.11154 0.1 -0.08165 0.057735
1.253 0.033519 -0.91362 -1.2653 -0.81714 0.97409 1.5701 0.0011236 0.83471 1.601 0.66772 0.94884 -0.09779 -2.0054 -0.4144 -0.025217 0.12633 0.032488 0.64186 1.4284 1.3912 0.0014171 0.12478 0.025243 0 0 0 0 0 0 0 0 0 0 306.54 -0.11214 0.10233 -0.086615 0.0659
1.1781 0.95734 -0.43246 -1.4601 -0.66632 0.93455 1.388 0.9165 0.18702 2.132 0.44398 0.87339 -0.074879 0.92382 0.48117 -0.19484 0.15082 -0.039532 0.39871 0.29787 2.4175 0.89132 0.18063 0.21647 0 0 0 0 0 0 0 0 0 0 307.95 -0.11269 0.10448 -0.091239 0.073603
1.1331 -0.55594 -0.93668 -1.2231 -0.67435 0.95728 1.284 0.30907 0.87736 1.496 0.45474 0.91639 -0.045007 -1.5133 -0.50422 0.237 -0.0080321 0.022727 0.16821 0.81481 2.1133 1.8594 0.0016358 0.0055193 0 0 0 0 0 0 0 0 0 0 307.75 -0.11319 0.10645 -0.095503 0.08079
1.0794 0.012593 -0.75276 -1.335 -0.61364 0.97318 1.1651 0.00015858 0.56665 1.7822 0.37655 0.94708 -0.053735 0.56853 0.18391 -0.11185 0.06071 0.015901 0.22543 0.11196 0.41896 0.25058 0.025912 0.0002289 0 0 0 0 0 0 0 0 0 0 308.52 -0.11365 0.10823 -0.09939 0.08741
1.1332 0.48589 -0.99342 -1.3215 -0.44246 0.94369 1.2841 0.23609 0.98689 1.7464 0.19577 0.89055 0.053787 0.4733 -0.24066 0.013469 0.17117 -0.029495 0.10352 0.07729 0.42122 0.028589 0.23487 0.1431 0 0 0 0 0 0 0 0 0 0 308.46 -0.11405 0.10982 -0.10288 0.093417
1.2264 -0.020975 -0.71618 -1.186 -0.60032 1.0067 1.504 0.00043997 0.51292 1.4067 0.36039 1.0134 0.093178 -0.50686 0.27724 0.13546 -0.15786 0.063 0.37644 0.092737 0.86903 0.67405 0.22987 0.17919 0 0 0 0 0 0 0 0 0 0 307.37 -0.1144 0.11122 -0.10597 0.098769
1.3325 0.8662 -1.0612 -1.1972 -0.57585 0.94382 1.7755 0.7503 1.1262 1.4332 0.33161 0.89079 0.10611 0.88718 -0.34503 -0.011125 0.02447 -0.062872 0.50314 0.27457 0.93641 0.001418 0.0030017 0.4456 0 0 0 0 0 0 0 0 0 0 308 -0.1147 0.11242 -0.10864 0.10343
1.4222 -0.57025 -0.78384 -1.2023 -1.0057 1.0845 2.0226 0.32518 0.6144 1.4454 1.0115 1.1761 0.0897 -1.4364 0.27738 -0.0050955 -0.42987 0.14065 0.3455 0.73446 0.86981 0.0048831 1.6293 1.2018 0 0 0 0 0 0 0 0 0 0 307.16 -0.11496 0.11342 -0.11089 0.10736
1.4478 1.6858 -1.1967 -1.2118 -0.68771 1.0644 2.0962 2.8421 1.432 1.4685 0.47294 1.133 0.025666 2.2561 -0.41284 -0.0095618 0.31802 -0.020064 0.012863 1.7891 1.38 0.0021171 0.83704 0.087943 0 0 0 0 0 0 0 0 0 0 307.42 -0.11516 0.11423 -0.11269 0.11054
1.4427 0.68909 -0.85908 -1.1878 -1.1139 1.1314 2.0814 0.47485 0.73802 1.4108 1.2408 1.28 -0.0051363 -0.99675 0.33759 0.024068 -0.42619 0.066959 0.013172 0.35484 1.2465 0.050952 1.6019 0.20941 0 0 0 0 0 0 0 0 0 0 306.98 -0.11531 0.11484 -0.11405 0.11295
1.3456 1.4611 -1.3238 -1.352 -0.92388 0.96464 1.8106 2.1348 1.7525 1.8279 0.85356 0.93053 -0.097123 0.77201 -0.46473 -0.16425 0.19001 -0.16672 0.63395 0.20752 1.7773 0.60934 0.29143 2.4571 0 0 0 0 0 0 0 0 0 0 307.57 -0.11541 0.11524 -0.11496 0.11456
1.3961 -0.37065 -0.91385 -1.4284 -0.95558 1.0758 1.949 0.13739 0.83512 2.0403 0.91314 1.1574 0.050491 -1.8318 0.40996 -0.076399 -0.031701 0.11119 0.088401 1.1924 1.7887 0.096817 0.012056 0.70716 0 0 0 0 0 0 0 0 0 0 308.03 -0.11546 0.11544 -0.11541 0.11537
______________________________________________________________
Outlier analysis
______________________________________________________________
global mean | global mean to var | spatial MAD | Missing values |
Warning: Converting dat field from double to single format
Warning: Columns of X are linearly dependent to within machine precision.
Using only the first 110 components to compute TSQUARED.
Retained 9 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 52.00%
Expected 7.50 outside 95% ellipsoid, found 14
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 0 images Cases
Uncorrected: 14 images Cases 10 19 57 61 87 95 96 97 102 103 128 129 138 140
Warning: Columns of X are linearly dependent to within machine precision.
Using only the first 111 components to compute TSQUARED.
Retained 9 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 50.00%
Expected 7.50 outside 95% ellipsoid, found 11
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 0 images Cases
Uncorrected: 11 images Cases 19 51 61 87 96 97 102 103 128 129 144
Mahalanobis (cov and corr, q<0.05 corrected):
0 images
Outlier_count Percentage
_____________ __________
global_mean 5 3.3333
global_mean_to_variance 5 3.3333
missing_values 0 0
rmssd_dvars 0 0
spatial_variability 3 2
mahal_cov_uncor 14 9.3333
mahal_cov_corrected 0 0
mahal_corr_uncor 11 7.3333
mahal_corr_corrected 0 0
Overall_uncorrected 23 15.333
Overall_corrected 9 6
Compressed NIfTI files are not supported.
Compressed NIfTI files are not supported.
Compressed NIfTI files are not supported.
SPM12: spm_check_registration (v7759) 01:04:50 - 27/03/2025
========================================================================
Display /Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/fmriprep20_template.nii.gz,1
(all) /Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/fmriprep20_template.nii.gz,1
/Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/fmriprep20_template.nii.gz,1
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
denoise_timeseries_pipeline finished.
Steps taken by denoise_timeseries_pipeline
1. Load the movement parameters file (mvmtfname) and compute 24 movement-related regressors.
2. If 'images_per_run' is provided, create run-specific intercept regressors and add these to the covariate matrix.
3. Identify spike and high framewise-displacement outlier images using outliers(), and append the resulting regressors.
4. Extract the mean CSF signal using extract_gray_white_csf() and add it as a regressor.
5. (Optional) Perform PCA-based denoising if 'pca_denoise' is true.
6. Apply a high-pass filter to the time series using use_spm_filter with TR and HP_cutoff_sec.
7. Rescale the combined nuisance covariates for visualization.
8. Visualize the final covariate matrix if requested
9. Regress out the nuisance covariates from the 4-D time series (using regress with residual and grand mean scaling).
10. Attach the covariates and metadata table to the denoised object.
11. Plot the denoised object data (if requested)
12. Save the denoised object to disk if requested.
A brief overview of steps
The code below loads some sample data and does the complete filtering and nuisance regression
% Load the key 4-D image file into an object
fname = which('swrsub-sid001567_task-pinel_acq-s1p2_run-03_bold.nii.gz');
obj = fmri_data(fname);
Using default mask: /Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/brainmask_canlab.nii
loading mask. mapping volumes.
checking that dimensions and voxel sizes of volumes are the same.
Pre-allocating data array. Needed: 145720800 bytes
Loading image number: 150
Elapsed time is 0.499009 seconds.
Image names entered, but fullpath attribute is empty. Getting path info.
.fullpath should have image name for each image column in .dat
Attempting to expand image filenames in case image list is unexpanded 4-D images
Number of unique values in dataset: 493 Bit rate: 8.95 bits
Warning: Number of unique values in dataset is low, indicating possible restriction of bit rate. For comparison, Int16 has 65,536 unique values
json_struct = jsondecode(fileread(which('sub-sid001567_task-pinel_acq-s1p2_run-03_bold.json')));
TR = json_struct.RepetitionTime;
% Obtain a matrix of 'spike' indicators and movement-related regressors
% based on multiple criteria to use as covariates
% 24 movement-related covariates per run
mvmtfname = which('rp_sub-sid001567_task-pinel_acq-s1p2_run-03_bold.txt');
[mvmt_matrix, mvmt_regs_24, mvmt_table] = movement_regressors(mvmtfname);
% 'spike' outliers and high framewise-displacement (fd) images
[est_outliers_uncorr, est_outliers_corr, outlier_tables] = outliers(obj, 'fd', mvmt_matrix);
______________________________________________________________
Outlier analysis
______________________________________________________________
global mean | global mean to var | spatial MAD | rmssd | Missing values | 0 images
Retained 2 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 18.67%
Expected 7.50 outside 95% ellipsoid, found 6
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 1 images Cases 1
Uncorrected: 6 images Cases 1 2 3 4 5 6
Retained 2 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 22.67%
Expected 7.50 outside 95% ellipsoid, found 6
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 1 images Cases 1
Uncorrected: 6 images Cases 1 2 3 4 5 6
Mahalanobis (cov and corr, q<0.05 corrected):
1 images
Framewise Displacement (before and after >0.50 mm correction):
0 images
Outlier_count Percentage
_____________ __________
global_mean 6 4
global_mean_to_variance 4 2.6667
missing_values 0 0
rmssd_dvars 1 0.66667
spatial_variability 4 2.6667
mahal_cov_uncor 6 4
mahal_cov_corrected 1 0.66667
mahal_corr_uncor 6 4
mahal_corr_corrected 1 0.66667
fd 0 0
Overall_uncorrected 10 6.6667
Overall_corrected 8 5.3333
sum(est_outliers_uncorr) % this shows how many outliers
covs = [covs outlier_tables.outlier_regressor_matrix_uncorr];
% build a table as well to save for later, with names
out_table = array2table(outlier_tables.outlier_regressor_matrix_uncorr);
out_table.Properties.VariableNames = strrep(out_table.Properties.VariableNames, 'Var', 'Out');
cov_table = [mvmt_table out_table];
[gwcsfvalues, gwcsfcomponents] = extract_gray_white_csf(obj);
Extracting from gray_matter_mask_sparse.img.
Removing 2565 voxels with one or more NaNs
Extracting from canonical_white_matter.img.
Removing 106 voxels with one or more NaNs
Extracting from canonical_ventricles.img.
Removing 158 voxels with one or more NaNs
meancsf = gwcsfvalues(:, 3);
cov_table = addvars(cov_table, meancsf, 'NewVariableNames','MeanCSF');
% Here the first component is a head-shift artifact; this will not always
% be the case. The second is highly related to head movement.
% You could use PCA or ICA denoising strategies but be
% careful. The 'pca_denoise' option in the pipeline will attempt to
% identify components strongly related to motion and reconstruct the data
% without them. But you could remove task-related variance too.
[component_scores, eigenmap_obj, explained] = pca(obj, 'k', 3);
Warning: Columns of X are linearly dependent to within machine precision.
Using only the first 2 components to compute TSQUARED.
% High-pass filter - Use TR read in earlier
[S,KL,KH] = use_spm_filter(TR, size(obj.dat, 2),'none', 'specify', HP_cutoff_sec);
% create high-pass filter table with names and add it
KH_table = array2table(KH);
KH_table.Properties.VariableNames = strrep(KH_table.Properties.VariableNames, 'Var', 'HPfilt');
cov_table = [cov_table KH_table];
% Rescale for convenience and visualization
covs = covs ./ max(abs(covs), [], 1);
% visualize the final cov matrix
create_figure('all covs');
set(gca, 'YDir', 'Reverse'); axis tight
colormap(colormap_tor([0 0 1], [1 1 0], [.2 .5 1], [.5 .5 .5], [1 .5 .2]))
% Regress all covs out from each voxel and return residuals
% We can ignore colinearity/leverage warnings
% - use the 'residual' option to return residuals after removing covariates
% - use the 'add_voxelwise_intercept' option to preserve the mean signal in
% each voxel. This doesn't matter if we are only calculating correlations,
% but can matter if we are doing anything that requires or interacts with
% maps of the overall level of signal in each voxel, like spatial
% correlations or SPM analyses with implicit masking.
% - use the 'grandmeanscale' option to rescale the entire 4-D dataset
% (usually run) to a grand mean of 100. This doesn't matter if we're only
% calculating within-run correlations, but matters if we are going to stack
% data across runs that may be on a different scale.
regress_output = regress(obj, 'residual', 'grandmeanscale', 'add_voxelwise_intercept', 'noverbose');
obj_denoised = regress_output.resid;
% Attach covs for later reference
obj_denoised.covariates = covs;
obj_denoised.metadata_table = cov_table;
disp('obj_denoised.metadata_table')
obj_denoised.metadata_table
obj_denoised.metadata_table
ans = 150×39 table
| mvmt_x | mvmt_y | mvmt_z | mvmt_roll | mvmt_pitch | mvmt_yaw | mvmt_x^2 | mvmt_y^2 | mvmt_z^2 | mvmt_roll^2 | mvmt_pitch^2 | mvmt_yaw^2 | mvmt_xdiff | mvmt_ydiff | mvmt_zdiff | mvmt_rolldiff | mvmt_pitchdiff | mvmt_yawdiff | mvmt_xdiff^2 | mvmt_ydiff^2 | mvmt_zdiff^2 | mvmt_rolldiff^2 | mvmt_pitchdiff^2 | mvmt_yawdiff^2 | Out1 | Out2 | Out3 | Out4 | Out5 | Out6 |
---|
1 | -0.1573 | -1.1991 | 3.2993 | 1.2974 | -1.8213 | -1.0474 | 0.0248 | 1.4379 | 10.8851 | 1.6833 | 3.3172 | 1.0971 | 0 | 0 | 0 | 0 | 0 | 0 | 0.0059 | 1.0776e-05 | 0.0074 | 0.0094 | 2.8598e-04 | 0.0150 | 1 | 0 | 0 | 0 | 0 | 0 |
---|
2 | -0.4925 | -1.3582 | 3.8513 | 1.2745 | -2.8581 | -1.2734 | 0.2426 | 1.8448 | 14.8327 | 1.6242 | 8.1685 | 1.6215 | -0.3352 | -0.1591 | 0.5521 | -0.0229 | -1.0367 | -0.2260 | 6.5524 | 0.0096 | 3.1375 | 6.5022e-04 | 9.3308 | 4.3304 | 0 | 1 | 0 | 0 | 0 | 0 |
---|
3 | -1.3909 | -0.7667 | 3.8426 | 1.1925 | -4.3719 | -1.9456 | 1.9346 | 0.5878 | 14.7655 | 1.4221 | 19.1133 | 3.7852 | -0.8984 | 0.5916 | -0.0087 | -0.0820 | -1.5138 | -0.6722 | 45.3207 | 0.1213 | 0.0035 | 0.1162 | 19.8245 | 35.3784 | 0 | 0 | 1 | 0 | 0 | 0 |
---|
4 | -1.6729 | -0.4491 | 3.6899 | 1.0493 | -4.1512 | -1.9579 | 2.7984 | 0.2017 | 13.6152 | 1.1010 | 17.2324 | 3.8335 | -0.2819 | 0.3176 | -0.1527 | -0.1432 | 0.2207 | -0.0124 | 4.6889 | 0.0344 | 0.1448 | 0.4467 | 0.3965 | 0.0529 | 0 | 0 | 0 | 1 | 0 | 0 |
---|
5 | -1.7716 | 1.2247 | 3.4342 | 1.0013 | -3.4948 | -2.1775 | 3.1384 | 1.4999 | 11.7937 | 1.0026 | 12.2136 | 4.7416 | -0.0987 | 1.6738 | -0.2557 | -0.0480 | 0.6564 | -0.2196 | 0.6528 | 0.9831 | 0.4828 | 0.0253 | 3.6342 | 4.1031 | 0 | 0 | 0 | 0 | 1 | 0 |
---|
6 | -2.1816 | -1.7807 | 2.7810 | 1.6438 | -2.9914 | -2.4684 | 4.7593 | 3.1710 | 7.7338 | 2.7022 | 8.9483 | 6.0932 | -0.4100 | -3.0054 | -0.6532 | 0.6425 | 0.5034 | -0.2909 | 9.6982 | 3.2023 | 3.6430 | 12.4649 | 2.1261 | 6.9900 | 0 | 0 | 0 | 0 | 0 | 1 |
---|
7 | -2.2071 | 0.1921 | 2.3810 | 1.6966 | -2.1391 | -2.3392 | 4.8713 | 0.0369 | 5.6693 | 2.8784 | 4.5760 | 5.4721 | -0.0255 | 1.9728 | -0.3999 | 0.0527 | 0.8522 | 0.1292 | 0.0707 | 1.3670 | 1.2889 | 0.1436 | 6.1512 | 0.9941 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
8 | -1.9208 | -0.2582 | 1.8876 | 1.8703 | -1.5973 | -2.0534 | 3.6895 | 0.0667 | 3.5629 | 3.4981 | 2.5513 | 4.2163 | 0.2863 | -0.4503 | -0.4935 | 0.1738 | 0.5419 | 0.2859 | 4.1788 | 0.0734 | 2.0190 | 1.0519 | 2.4674 | 5.5452 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
9 | -1.6532 | 0.1057 | 1.2791 | 1.9866 | -0.3026 | -1.6557 | 2.7331 | 0.0112 | 1.6360 | 3.9464 | 0.0916 | 2.7412 | 0.2676 | 0.3639 | -0.6085 | 0.1162 | 1.2947 | 0.3977 | 3.6321 | 0.0454 | 3.1403 | 0.5159 | 14.2623 | 11.0479 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
10 | -1.3900 | 0.7609 | 0.5895 | 1.9495 | -0.2146 | -1.5776 | 1.9322 | 0.5790 | 0.3475 | 3.8006 | 0.0461 | 2.4889 | 0.2632 | 0.6552 | -0.6896 | -0.0370 | 0.0880 | 0.0780 | 3.5071 | 0.1491 | 4.0790 | 0.0102 | 0.0580 | 0.3064 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
11 | -1.4473 | -1.0571 | 1.0689 | 2.0610 | -0.0224 | -1.5040 | 2.0947 | 1.1174 | 1.1425 | 4.2477 | 5.0229e-04 | 2.2621 | -0.0573 | -1.8180 | 0.4794 | 0.1115 | 0.1922 | 0.0736 | 0.2510 | 1.1745 | 2.4009 | 0.4800 | 0.2985 | 0.2656 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
12 | -1.4445 | -0.0520 | 0.8184 | 1.8435 | -0.2637 | -1.6727 | 2.0865 | 0.0027 | 0.6699 | 3.3986 | 0.0695 | 2.7978 | 0.0028 | 1.0051 | -0.2504 | -0.2175 | -0.2413 | -0.1687 | 0.0031 | 0.3529 | 0.4609 | 1.1342 | 0.5239 | 2.5099 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
13 | -1.4448 | -1.6969 | 1.1674 | 1.9769 | -0.1672 | -1.5592 | 2.0875 | 2.8796 | 1.3629 | 3.9080 | 0.0279 | 2.4312 | -3.3265e-04 | -1.6450 | 0.3490 | 0.1333 | 0.0965 | 0.1134 | 0.0063 | 0.9622 | 1.3255 | 0.6556 | 0.0707 | 0.7405 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
14 | -1.0211 | 0.4363 | 1.0126 | 1.8334 | -0.0398 | -1.3648 | 1.0427 | 0.1903 | 1.0254 | 3.3612 | 0.0016 | 1.8628 | 0.4237 | 2.1332 | -0.1548 | -0.1435 | 0.1273 | 0.1944 | 9.3757 | 1.5991 | 0.1497 | 0.4487 | 0.1269 | 2.4393 | 0 | 0 | 0 | 0 | 0 | 0 |
---|
⋮ |
---|
obj_denoised = enforce_variable_types(obj_denoised);
A detailed overview of each step
Step 1. Set Up Your Environment
1. Download and Install CANLAB Toolboxes:
- Visit CANLAB.github.io and download the latest version of the CANLAB tools.
- Add the CANLAB toolbox directories to your MATLAB path with subfolders.
- Make sure you have other required dependencies, including SPM for its file reading/writing and orthviews routines).
2. Prepare Your Inputs:
- Time Series Data: A 4-D NIfTI file per participant (e.g., from fmriprep).
- Motion and Outlier Information: fmriprep output files or similar that contain motion parameters. You can also use fmriprep's displacement measures and spike regressors, but the pipeline and example here is self-contained, and we don't use them.
Step 2. Create the fmri_data Object
The fmri_data object in CANLAB is a container that holds your fMRI data along with metadata and processing options. We will do this by loading a NIFTI (.nii) file with smoothed, warped, realigned fMRI time series images from a sample run.
% Load the key 4-D image file
fname = which('swrsub-sid001567_task-pinel_acq-s1p2_run-03_bold.nii.gz');
obj = fmri_data(fname);
Using default mask: /Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/brainmask_canlab.nii
loading mask. mapping volumes.
checking that dimensions and voxel sizes of volumes are the same.
Pre-allocating data array. Needed: 145720800 bytes
Loading image number: 150
Elapsed time is 0.460028 seconds.
Image names entered, but fullpath attribute is empty. Getting path info.
.fullpath should have image name for each image column in .dat
Attempting to expand image filenames in case image list is unexpanded 4-D images
Number of unique values in dataset: 493 Bit rate: 8.95 bits
Warning: Number of unique values in dataset is low, indicating possible restriction of bit rate. For comparison, Int16 has 65,536 unique values
A more in-depth explanation is below.
Sample data
Orientation to Pinel data files
The Pinel Localizer task was designed to probe several different types of basic cognitive processes, such as visual perception, finger tapping, language, and math. Several of the tasks are cued by reading text on the screen (i.e., visual modality) and also by hearing auditory instructions (i.e., auditory modality). The trials are randomized across conditions and have been optimized to maximize efficiency for a rapid event related design. There are 100 trials in total over a 5-minute scanning session. Read the original paper for more specific details about the task and the dataset paper. This dataset is well suited for these tutorials as it is (a) publicly available to anyone in the world, (b) relatively small (only about 5min), and (c) provides many options to create different types of contrasts. There are a total of 94 subjects available.
Our Pinel_data_sample_subject is from an individual collected at Dartmouth's Brain Imaging Center (DBIC). It is organized in a particular standardized file format called BIDS (Brain imaging Data structure). The whole dataset is available in BIDS format from Luke Chang's g-node GIN repository. To have a look at this, let's go to the Pinel_data_sample_subject folder. Drag and drop it into your Command Window, or drag the folder into Terminal (Mac) and copy the path, then use the cd( ) command in Matlab. e.g.,
Now, let's look at the files:
ls % list files
mwc1sub-sid001567_acq-MPRAGE_T1w.nii
rp_sub-sid001567_task-pinel_acq-s1p2_run-03_bold.txt
sub-sid001567_task-pinel_acq-s1p2_run-03_bold.json
sub-sid001567_task-pinel_acq-s1p2_run-03_bold_full_design_matrix.png
sub-sid001567_task-pinel_acq-s1p2_run-03_events.tsv
swrsub-sid001567_task-pinel_acq-s1p2_run-03_bold.nii.gz
swrsub-sid001567_task-pinel_acq-s1p2_run-03_bold_denoised.mat
The main files we're interested in are:
sub-sid001567_task-pinel_acq-s1p2_run-03_bold.nii
The image data in 4-D Nifti format
sub-sid001567_task-pinel_acq-s1p2_run-03_events.tsv
The task events + their onset times
The rp_.txt file is only created after realignment of the functional images, a preprocessing step. We'll assume this is done already for now (which it was for this sample participant).
After realignment with SPM software (or similar), some new files are created:
rp_sub-sid001567_task-pinel_acq-s1p2_run-03_bold.txt
The "realignment parameters" (rp), head motion estimates, with translation and rotation for each image required to match it to the reference image (often the first image in the series or an average image)
sub-sid001567_task-pinel_acq-s1p2_run-03_bold.mat
Matlab transformation matrices describing the voxel sizes, origin (zero-coordinate), and rotation for each image
rsub-sid001567_task-pinel_acq-s1p2_run-03_bold.nii
The realigned image data, with the transformations (i.e., rotation/translation) applied
swrsub-sid001567_task-pinel_acq-s1p2_run-03_bold.nii.gz
Smoothed (s), warped to MNI template (w), and realigned (r) 4-D image series. This is the one we are going to load and use for this example.
To construct a design matrix for first-level analysis (see below), we're mainly interested in two files: The task (.tsv) file that tells us how to construct the regressors of interest, and the rp*.txt file that we'll use as a set of nuisance covariates. Step 3. Build the Nuisance Covariate Model
The goal is to create a design matrix that captures nuisance variance from multiple sources. This matrix typically includes:
1. Intercepts: Use intercept_model.m to generate indicator matrices for each run or session.
This example dataset only includes one run, so we will omit it here, but it is important to include for multi-run data.
2. Motion Parameters: Extract the 24 motion parameters per run (e.g., translations, rotations, and their derivatives/squares) from your fmriprep or SPM outputs.
% 24 movement-related covariates per run
mvmtfname = which('rp_sub-sid001567_task-pinel_acq-s1p2_run-03_bold.txt');
[mvmt_matrix, mvmt_regs_24] = movement_regressors(mvmtfname);
Let's plot them:
figure; plot(mvmt_matrix);
legend({'x' 'y' 'z' 'roll' 'pitch' 'yaw'});
title('Movement regressors')
3. Mean CSF Signal: Use either the fmriprep output or the CANLAB function:FD = FD.extract_gray_white_csf();
[gwcsfvalues, gwcsfcomponents] = extract_gray_white_csf(obj);
Extracting from gray_matter_mask_sparse.img.
Removing 2565 voxels with one or more NaNs
Extracting from canonical_white_matter.img.
Removing 106 voxels with one or more NaNs
Extracting from canonical_ventricles.img.
Removing 158 voxels with one or more NaNs
meancsf = gwcsfvalues(:, 3);
This extracts average signals from CSF (and optionally gray and white matter).
4. Spike Regressors:Identify and flag time points with unusual signal spikes (e.g., using FD.outliers).
5. High Displacement Time Points:Incorporate additional covariates for time points with high head displacement, as measured by geometric displacement metrics from fmriprep.
% 'spike' outliers and high framewise-displacement (fd) images
[est_outliers_uncorr, est_outliers_corr, outlier_tables] = outliers(obj, 'fd', mvmt_matrix);
______________________________________________________________
Outlier analysis
______________________________________________________________
global mean | global mean to var | spatial MAD | rmssd | Missing values | 0 images
Retained 2 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 18.67%
Expected 7.50 outside 95% ellipsoid, found 6
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 1 images Cases 1
Uncorrected: 6 images Cases 1 2 3 4 5 6
Retained 2 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 22.67%
Expected 7.50 outside 95% ellipsoid, found 6
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 1 images Cases 1
Uncorrected: 6 images Cases 1 2 3 4 5 6
Mahalanobis (cov and corr, q<0.05 corrected):
1 images
Framewise Displacement (before and after >0.50 mm correction):
0 images
Outlier_count Percentage
_____________ __________
global_mean 6 4
global_mean_to_variance 4 2.6667
missing_values 0 0
rmssd_dvars 1 0.66667
spatial_variability 4 2.6667
mahal_cov_uncor 6 4
mahal_cov_corrected 1 0.66667
mahal_corr_uncor 6 4
mahal_corr_corrected 1 0.66667
fd 0 0
Overall_uncorrected 10 6.6667
Overall_corrected 8 5.3333
sum(est_outliers_uncorr) % this shows how many outliers
% each outlier or high-fd image gets its own regressor
covs = [covs outlier_tables.outlier_regressor_matrix_uncorr];
6. High-Pass Filter (HPF) Regressors:Generate HPF regressors to remove low-frequency drift.
For example, using SPM’s filtering functions:
cutoff = 128; % Example cutoff in seconds; adjust as needed
Note that we need to know the TR for this! It's 2 sec. In BIDS formatted data, this can be found in the ".json sidecar" file, in the "RepetitionTime" field. We also need the scan length in sec, which in this case is 300 sec or 5 min.
% High-pass filter - TR = 2 sec for this example
[S,KL,KH] = use_spm_filter(TR, size(obj.dat, 2), 'none', 'specify', HP_cutoff_sec);
covs: Combined nuisance regressors into nuisance design matrix X
The various sets of regressors are concatenated into one matrix, covs.
This includes intercept, motion, CSF, spikes, high displacement (movement), HPF matrix
Step 4. Regress Out Nuisance Signals
Now, remove the nuisance variance from each voxel’s time series. The fmri_data.regress method with the 'residual' option performs this operation:
% Regress nuisance signals; output is the residual time series (denoised)
obj_denoised = obj.regress(nuisanceMat, 'residual');
Regress all covs out from each voxel and return residuals
- Use the 'residual' option to return residuals after removing covariates
- Use the 'add_voxelwise_intercept' option to preserve the mean signal in each voxel. This doesn't matter if we are only calculating correlations, but can matter if we are doing anything that requires or interacts with maps of the overall level of signal in each voxel, like spatial correlations or SPM analyses with implicit masking.
- Use the 'grandmeanscale' option to rescale the entire 4-D dataset (usually run) to a grand mean of 100. This doesn't matter if we're only calculating within-run correlations, but matters if we are going to stack data across runs that may be on a different scale.
% Regress all covs out from each voxel and return residuals
% We can ignore colinearity/leverage warnings
regress_output = regress(obj, 'residual', 'grandmeanscale', 'add_voxelwise_intercept', 'noverbose');
obj_denoised = regress_output.resid;
% Attach covs for later reference
obj_denoised.covariates = covs;
obj_denoised.metadata_table = cov_table;
After this step, obj_denoised holds the denoised 4-D time series for further analysis.
% Visualize the cleaned data
plot(obj_denoised)
______________________________________________________________
Outlier analysis
______________________________________________________________
global mean | global mean to var | spatial MAD | Missing values |
Warning: Converting dat field from double to single format
Warning: Columns of X are linearly dependent to within machine precision.
Using only the first 110 components to compute TSQUARED.
Retained 9 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 52.00%
Expected 7.50 outside 95% ellipsoid, found 14
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 0 images Cases
Uncorrected: 14 images Cases 10 19 57 61 87 95 96 97 102 103 128 129 138 140
Warning: Columns of X are linearly dependent to within machine precision.
Using only the first 111 components to compute TSQUARED.
Retained 9 components for mahalanobis distance
Expected 50% of points within 50% normal ellipsoid, found 50.00%
Expected 7.50 outside 95% ellipsoid, found 11
Potential outliers based on mahalanobis distance:
Bonferroni corrected: 0 images Cases
Uncorrected: 11 images Cases 19 51 61 87 96 97 102 103 128 129 144
Mahalanobis (cov and corr, q<0.05 corrected):
0 images
Outlier_count Percentage
_____________ __________
global_mean 5 3.3333
global_mean_to_variance 5 3.3333
missing_values 0 0
rmssd_dvars 0 0
spatial_variability 3 2
mahal_cov_uncor 14 9.3333
mahal_cov_corrected 0 0
mahal_corr_uncor 11 7.3333
mahal_corr_corrected 0 0
Overall_uncorrected 23 15.333
Overall_corrected 9 6
Compressed NIfTI files are not supported.
Compressed NIfTI files are not supported.
Compressed NIfTI files are not supported.
SPM12: spm_check_registration (v7759) 01:13:48 - 27/03/2025
========================================================================
Display /Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/fmriprep20_template.nii.gz,1
(all) /Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/fmriprep20_template.nii.gz,1
/Users/f003vz1/Documents/GitHub/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/fmriprep20_template.nii.gz,1
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
Step 5. Optional: Explore how nuisance covs overlap with task design
Create a task design matrix from the Pinel task file.
To construct a design matrix for first-level analysis (see below), we're mainly interested in two files: The task (.tsv) file that tells us how to construct the regressors of interest, and the rp*.txt file that we'll use as a set of nuisance covariates, which we have already dealt with. Load the realignment parameters and create a set of nuisance covariates
% Load the onsets file into a table object in matlab
taskdata = readtable('sub-sid001567_task-pinel_acq-s1p2_run-03_events.tsv', 'FileType', 'text');
taskdata
taskdata = 80×3 table
| onset | duration | trial_type |
---|
1 | 0 | 1 | 'video_computation' |
---|
2 | 2.4000 | 1 | 'video_computation' |
---|
3 | 8.7000 | 1 | 'horizontal_checkerboard' |
---|
4 | 11.4000 | 1 | 'audio_right_hand' |
---|
5 | 15 | 1 | 'audio_sentence' |
---|
6 | 18 | 1 | 'video_right_hand' |
---|
7 | 20.7000 | 1 | 'audio_sentence' |
---|
8 | 23.7000 | 1 | 'audio_left_hand' |
---|
9 | 26.7000 | 1 | 'video_left_hand' |
---|
10 | 29.7000 | 1 | 'audio_sentence' |
---|
11 | 33 | 1 | 'vertical_checkerboard' |
---|
12 | 35.4000 | 1 | 'audio_computation' |
---|
13 | 39 | 1 | 'video_sentence' |
---|
14 | 41.7000 | 1 | 'video_sentence' |
---|
⋮ |
---|
% Use a CANlab function to extract the conditions (event types) and which
% events belong to each type
[indic, tasknames] = string2indicator(taskdata.trial_type);
% Get a cell array of onsets for each condition
[ons, ons_with_durations] = deal(cell(1, length(tasknames)));
for i = 1:length(tasknames)
ons{i} = taskdata.onset(indic(:, i));
ons_with_durations{i} = taskdata.onset(indic(:, i));
ons_with_durations{i}(:, 2) = taskdata.duration(indic(:, i));
Now, we've extracted the information in a format we can use to construct a design matrix. Let's try it.
Note that we need to know the TR for this! It's 2 sec. In BIDS formatted data, this can be found in the ".json sidecar" file, in the "RepetitionTime" field. We also need the scan length in sec, which in this case is 300 sec or 5 min.
X = onsets2fmridesign(ons, TR, 300);
This returns the task design matrix, X -- or at least the portion of it of interest. The full design matrix would also include the nuisance covariates.
We can look at the Variance Inflation Factors to see whether there are mulitcolinearity issues or not. We'll use the 'plot' option and save the handle to this figure so we can re-activate it and add things later:
fig_han = create_figure('vifs'); % Get handle to current figure
vifs = getvif(X, 0, 'plot');
Variance inflation: 1 (black line) = minimum possible (best)
Successive lines indicate doublings of variance inflation factor.
Red boxes have extremely high VIFs, perfect multicolinearity
title('Var. inflation factors without nuisance covs')
Now let's see how VIFs are affected by nuisance covs:
fig_han = create_figure('vifs_with_covs'); % Get handle to current figure
vifs = getvif([X covs], 0, 'plot');
Variance inflation: 1 (black line) = minimum possible (best)
Successive lines indicate doublings of variance inflation factor.
Red boxes have extremely high VIFs, perfect multicolinearity
% We are interested in the task regs only, so zoom in on those:
set(gca, 'XLim', [0 10], 'YLim', [0 max(10, max(vifs(1:10)) + 0.5)]);
title('Var. inflation factors with nuisance covs')
Attach the onsets and task regressors for later reference.
obj_denoised.additional_info{1} = ons_with_durations;
obj_denoised.additional_info{2} = 'Cell array of onsets (:, 1) and durations (:, 2) for 10 event types';
obj_denoised.additional_info{3} = tasknames;
% Add task regressors to the metadata_table table object
t = obj_denoised.metadata_table;
tasknames{end + 1} = 'Intercept';
% Check that the number of columns in X matches the number of task names
if size(X,2) ~= numel(tasknames)
error('Mismatch: X has %d columns, but tasknames contains %d names.', size(X,2), numel(tasknames));
% Check that the number of rows in X equals the number of rows in t
if ~isempty(t) && size(X,1) ~= height(t)
error('Row count mismatch: X has %d rows, but table t has %d rows.', size(X,1), height(t));
% Convert X into a table using tasknames as variable names
task_table = array2table(X, 'VariableNames', tasknames);
% Add the new columns to table t
obj_denoised.metadata_table = t;
Show the full design matrix
obj_denoised.metadata_table
ans = 150×50 table
| audio_computation | audio_left_hand | audio_right_hand | audio_sentence | horizontal_checkerboard | vertical_checkerboard | video_computation | video_left_hand | video_right_hand | video_sentence | Intercept | mvmt_x | mvmt_y | mvmt_z | mvmt_roll | mvmt_pitch | mvmt_yaw | mvmt_x^2 | mvmt_y^2 | mvmt_z^2 | mvmt_roll^2 | mvmt_pitch^2 | mvmt_yaw^2 | mvmt_xdiff | mvmt_ydiff | mvmt_zdiff | mvmt_rolldiff | mvmt_pitchdiff | mvmt_yawdiff | mvmt_xdiff^2 |
---|
1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | -0.1573 | -1.1991 | 3.2993 | 1.2974 | -1.8213 | -1.0474 | 0.0248 | 1.4379 | 10.8851 | 1.6833 | 3.3172 | 1.0971 | 0 | 0 | 0 | 0 | 0 | 0 | 0.0059 |
---|
2 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2057 | 0 | 0 | 0 | 1 | -0.4925 | -1.3582 | 3.8513 | 1.2745 | -2.8581 | -1.2734 | 0.2426 | 1.8448 | 14.8327 | 1.6242 | 8.1685 | 1.6215 | -0.3352 | -0.1591 | 0.5521 | -0.0229 | -1.0367 | -0.2260 | 6.5524 |
---|
3 | 0 | 0 | 0 | 0 | 0 | 0 | 0.9968 | 0 | 0 | 0 | 1 | -1.3909 | -0.7667 | 3.8426 | 1.1925 | -4.3719 | -1.9456 | 1.9346 | 0.5878 | 14.7655 | 1.4221 | 19.1133 | 3.7852 | -0.8984 | 0.5916 | -0.0087 | -0.0820 | -1.5138 | -0.6722 | 45.3207 |
---|
4 | 0 | 0 | 0 | 0 | 0 | 0 | 1.7070 | 0 | 0 | 0 | 1 | -1.6729 | -0.4491 | 3.6899 | 1.0493 | -4.1512 | -1.9579 | 2.7984 | 0.2017 | 13.6152 | 1.1010 | 17.2324 | 3.8335 | -0.2819 | 0.3176 | -0.1527 | -0.1432 | 0.2207 | -0.0124 | 4.6889 |
---|
5 | 0 | 0 | 0 | 0 | 0 | 0 | 1.4778 | 0 | 0 | 0 | 1 | -1.7716 | 1.2247 | 3.4342 | 1.0013 | -3.4948 | -2.1775 | 3.1384 | 1.4999 | 11.7937 | 1.0026 | 12.2136 | 4.7416 | -0.0987 | 1.6738 | -0.2557 | -0.0480 | 0.6564 | -0.2196 | 0.6528 |
---|
6 | 0 | 0 | 0 | 0 | 0.0498 | 0 | 0.7742 | 0 | 0 | 0 | 1 | -2.1816 | -1.7807 | 2.7810 | 1.6438 | -2.9914 | -2.4684 | 4.7593 | 3.1710 | 7.7338 | 2.7022 | 8.9483 | 6.0932 | -0.4100 | -3.0054 | -0.6532 | 0.6425 | 0.5034 | -0.2909 | 9.6982 |
---|
7 | 0 | 0 | 0.0024 | 0 | 0.6900 | 0 | 0.2360 | 0 | 0 | 0 | 1 | -2.2071 | 0.1921 | 2.3810 | 1.6966 | -2.1391 | -2.3392 | 4.8713 | 0.0369 | 5.6693 | 2.8784 | 4.5760 | 5.4721 | -0.0255 | 1.9728 | -0.3999 | 0.0527 | 0.8522 | 0.1292 | 0.0707 |
---|
8 | 0 | 0 | 0.4289 | 0 | 0.9905 | 0 | -0.0447 | 0 | 0 | 0 | 1 | -1.9208 | -0.2582 | 1.8876 | 1.8703 | -1.5973 | -2.0534 | 3.6895 | 0.0667 | 3.5629 | 3.4981 | 2.5513 | 4.2163 | 0.2863 | -0.4503 | -0.4935 | 0.1738 | 0.5419 | 0.2859 | 4.1788 |
---|
9 | 0 | 0 | 0.9854 | 0.0175 | 0.6581 | 0 | -0.1527 | 0 | 0 | 0 | 1 | -1.6532 | 0.1057 | 1.2791 | 1.9866 | -0.3026 | -1.6557 | 2.7331 | 0.0112 | 1.6360 | 3.9464 | 0.0916 | 2.7412 | 0.2676 | 0.3639 | -0.6085 | 0.1162 | 1.2947 | 0.3977 | 3.6321 |
---|
10 | 0 | 0 | 0.8023 | 0.5747 | 0.2778 | 0 | -0.1621 | 0 | 0 | 0 | 1 | -1.3900 | 0.7609 | 0.5895 | 1.9495 | -0.2146 | -1.5776 | 1.9322 | 0.5790 | 0.3475 | 3.8006 | 0.0461 | 2.4889 | 0.2632 | 0.6552 | -0.6896 | -0.0370 | 0.0880 | 0.0780 | 3.5071 |
---|
11 | 0 | 0 | 0.3929 | 1 | 0.0511 | 0 | -0.1262 | 0 | 0.2057 | 0 | 1 | -1.4473 | -1.0571 | 1.0689 | 2.0610 | -0.0224 | -1.5040 | 2.0947 | 1.1174 | 1.1425 | 4.2477 | 5.0229e-04 | 2.2621 | -0.0573 | -1.8180 | 0.4794 | 0.1115 | 0.1922 | 0.0736 | 0.2510 |
---|
12 | 0 | 0 | 0.1125 | 0.7746 | -0.0550 | 0 | -0.0810 | 0 | 0.8908 | 0 | 1 | -1.4445 | -0.0520 | 0.8184 | 1.8435 | -0.2637 | -1.6727 | 2.0865 | 0.0027 | 0.6699 | 3.3986 | 0.0695 | 2.7978 | 0.0028 | 1.0051 | -0.2504 | -0.2175 | -0.2413 | -0.1687 | 0.0031 |
---|
13 | 0 | 1.0357e-04 | -0.0287 | 1.0177 | -0.0881 | 0 | -0.0449 | 0 | 0.9147 | 0 | 1 | -1.4448 | -1.6969 | 1.1674 | 1.9769 | -0.1672 | -1.5592 | 2.0875 | 2.8796 | 1.3629 | 3.9080 | 0.0279 | 2.4312 | -3.3265e-04 | -1.6450 | 0.3490 | 0.1333 | 0.0965 | 0.1134 | 0.0063 |
---|
14 | 0 | 0.3110 | -0.0827 | 1.0676 | -0.0805 | 0 | -0.0221 | 0 | 0.5136 | 0 | 1 | -1.0211 | 0.4363 | 1.0126 | 1.8334 | -0.0398 | -1.3648 | 1.0427 | 0.1903 | 1.0254 | 3.3612 | 0.0016 | 1.8628 | 0.4237 | 2.1332 | -0.1548 | -0.1435 | 0.1273 | 0.1944 | 9.3757 |
---|
⋮ |
---|
create_figure('Full design matrix');
rescale_fcn = @(X) X ./ max(abs(X), [], 1); % rescale columns of X to [1 -1]
X = rescale_fcn(table2array(obj_denoised.metadata_table));
set(gca, 'YDir', 'Reverse'); axis tight
colormap(colormap_tor([0 0 1], [1 1 0], [.2 .5 1], [.5 .5 .5], [1 .5 .2]))

Step 6 (optional). Save the Preprocessed Data
Store the denoised fmri_data object and any relevant nuisance matrices for subsequent analyses:
This file can be loaded later for connectivity analyses or model fitting.
Step 7. Analysis: Connectivity and Custom RL Models
Once you have the cleaned data, you can proceed with various analyses:
A. Connectivity Analysis
1. Extract Regional Time Series:Use functions such as extract_data (or the CANLAB-supported brainpathway tools) to get time series from regions of interest (ROIs).% Example: extract time series for a specific ROI
2. Compute Connectivity Metrics:You can calculate correlation matrices, graph metrics, or other connectivity measures from the extracted time series.
See canlab_connectivity_predict()
B. Custom Reinforcement Learning (RL) Models
1. Prepare the Data for Modeling:Use the denoised voxel or ROI time series as inputs to your RL model.For instance, you might extract trial-by-trial signals aligned to task events.
2. Fit Your RL Model:Implement your RL model (e.g., using MATLAB’s optimization or Bayesian tools). You may code the model in MATLAB or interface with Python (e.g., via MATLAB’s Engine API).
3. Evaluate Model Performance:Analyze the model parameters, compare with behavioral data, or run statistical tests (e.g., using fitlme, igls, or CANLAB’s fmri_data.regress for second-level analysis).
Summary
- Data Loading:Read the 4-D NIfTI into an fmri_data object.
- Nuisance Modeling:Build a nuisance regressor matrix using intercepts, motion, CSF, spike, high displacement, and HPF regressors.
- Denoising:Regress out the nuisance signals to create a cleaned dataset.
- Saving:Save the denoised data and nuisance matrices.
- Analyses:
- Connectivity: Extract ROI time series and compute connectivity measures.
- RL Modeling: Fit your custom reinforcement learning model to the cleaned time series.
By following these steps and using the CANLAB toolset, you can efficiently pre-process your fMRI data and set the stage for advanced connectivity and model-based analyses. Happy analyzing!