Skip to content

Commit b184419

Browse files
torwagerclaude
andauthored
codespell: fix typos surfaced on master; whitelist hask (#84)
The codespell gate (merged via #53) was red on master because newer code (merged via #53/#70/#79) contained typos the original sweep never saw. Fix real comment typos: exlude->exclude, meaninful->meaningful (canlab_pattern_similarity.m); INTIALIZE->INITIALIZE (hansen_neurotransmitter_maps.m); and saggital/immmediately/iamges/waht/ sigificant/Treshold in the vendored walkthrough snapshot scripts (Unit_tests/walkthroughs/private/canlab_help_*.m). All are in comments. Whitelist 'hask' -- an intentional "has key" anonymous-function helper in canlab_colormap.m and @fmridisplay/render_layer_surfaces.m. codespell now exits clean. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 68b0a7e commit b184419

11 files changed

Lines changed: 311 additions & 14 deletions

.codespellrc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,6 @@ ignore-regex = https?://\S+|^% data: \{"dataType":"image".*
2626
# atleast, whch, whn, includ -- variable names (renaming would break code; "atleast" -> "at least" would be a syntax error)
2727
# efficency -- legacy function file name OptimizeDesign11/core_functions/efficency.m (sibling efficiency.m is the newer version; both retained)
2828
# ony, nam, tha, thre, firt, jus -- ambiguous variable/string fragments in context
29-
ignore-words-list = ons,ans,fpr,ttests,myu,whos,ser,htmp,fwe,dout,ttest,indx,alph,te,ist,selt,multy,shft,delt,dum,datin,fixin,runn,nneeded,figurestyle,cxan,losin,commun,pres,ues,assignin,evalin,inout,ment,sepulcre,shepard,shure,claus,lew,nd,ore,fo,atmost,sessons,lightening,prctiles,atleast,whch,whn,includ,efficency,ony,nam,tha,thre,firt,jus
29+
# hask -- local "has key" anonymous-function helper (`hask = @(k) any(strcmp(args,k))`)
30+
# in canlab_colormap.m and @fmridisplay/render_layer_surfaces.m
31+
ignore-words-list = ons,ans,fpr,ttests,myu,whos,ser,htmp,fwe,dout,ttest,indx,alph,te,ist,selt,multy,shft,delt,dum,datin,fixin,runn,nneeded,figurestyle,cxan,losin,commun,pres,ues,assignin,evalin,inout,ment,sepulcre,shepard,shure,claus,lew,nd,ore,fo,atmost,sessons,lightening,prctiles,atleast,whch,whn,includ,efficency,ony,nam,tha,thre,firt,jus,hask

CanlabCore/@image_vector/hansen_neurotransmitter_maps.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
end
207207

208208
% -------------------------------------------------------------------------
209-
% INTIALIZE OUTPUT
209+
% INITIALIZE OUTPUT
210210
% -------------------------------------------------------------------------
211211
stats = struct();
212212
[hh, hhfill] = deal(' ');

CanlabCore/Statistics_tools/canlab_pattern_similarity.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
% By default, data images with values of zero or NaN are considered out-of-mask, as they
9494
% are not valid values. That is, 0 is typically treated as a missing data value in images
9595
% This can be changed by setting ['treat_zero_as_data', true].
96-
% This function does not exlude 0 voxels from the pattern_mask input, where it is assumed
97-
% that 0 is a meaninful value (for a neuromarker or binary mask).
96+
% This function does not exclude 0 voxels from the pattern_mask input, where it is assumed
97+
% that 0 is a meaningful value (for a neuromarker or binary mask).
9898
% Thus, this function treats values of 0 in DATA images, not pattern masks,
9999
% as missing values, and excludes these voxels from both image and
100100
% mask when calculating similarity.
Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
%% Datasets used in CANlab tutorials
2+
%
3+
% Note: this report was generated from |canlab_help_2c_loading_datasets.m|
4+
% in the repository <https://github.com/canlab/CANlab_help_examples>
5+
%
6+
7+
%% The Neuroimaging_pattern_masks Github repository and website
8+
%
9+
% For these walkthroughs, we'll load several image datasets.
10+
% Some are stored in Github, if the files are small enough.
11+
% The Wager 2008 emotion regulation dataset, for example, is
12+
% in the CANlab Core repository. Others are on figshare or Neurovault.
13+
%
14+
% Many tutorials apply pre-trained patterns and masks.
15+
% These are stored in this Github repository:
16+
%
17+
% <https://github.com/canlab/Neuroimaging_Pattern_Masks>
18+
%
19+
% In addition, you can explore these and find more information here:
20+
% <https://sites.google.com/dartmouth.edu/canlab-brainpatterns/home>
21+
%
22+
% To run this tutorial and many others in this series, you'll need to
23+
% download the Neuroimaging_Pattern_Masks Github repository and add it to
24+
% your Matlab path with subfolders.
25+
% The Github site has three main types of datasets, shown here:
26+
%
27+
% <<Neuroimaging_pattern_masks_site.png>>
28+
%
29+
%% Registries for easy loading
30+
% There are several functions that contain sets of images that you can load
31+
% by name. For example:
32+
%
33+
% |load_image_set()| includes a registry of datasets that you can access by
34+
% name. Try |help load_image|set| for a list of images you can load by
35+
% keyword.
36+
%
37+
% |load_atlas()| also has a named set of atlases/brain parcellations you can load.
38+
%
39+
% |canlab_load_ROI| has a registry of many named regions derived from previous
40+
% studies. This is particularly useful for loading a subcortical ROI and
41+
% visualizing it or applying it to data.
42+
43+
%% Emotion regulation dataset
44+
% "Wager_et_al_2008_Neuron_EmotionReg"
45+
% The dataset is a series of contrast images from N = 30 participants.
46+
% Each image is a contrast image for [reappraise neg vs. look neg]
47+
%
48+
% These data were published in:
49+
% Wager, T. D., Davidson, M. L., Hughes, B. L., Lindquist, M. A.,
50+
% Ochsner, K. N.. (2008). Prefrontal-subcortical pathways mediating
51+
% successful emotion regulation. Neuron, 59, 1037-50.
52+
%
53+
% To load, try the following:
54+
55+
[data_obj, subject_names, image_names] = load_image_set('emotionreg', 'noverbose');
56+
57+
montage(mean(data_obj), 'trans', 'compact2');
58+
drawnow, snapnow
59+
60+
% data_obj is an fmri_data object containing all 30 images.
61+
% subject_names is a list of short names for each image.
62+
% image_names is a list of the full image names with their path.
63+
64+
%% Buckner lab resting-state connectivity maps
65+
%
66+
% A popular series of masks is a set of "networks" developed from resting-state fMRI
67+
% connectivity in 1,000 people. For our purposes, the "network" maps
68+
% consist of a set of voxels that load most highly on each of 7 ICA
69+
% components from the 1,000 Functional Connectomes project.
70+
% These were published by Randy Buckner's lab in 2011 in three papers:
71+
% Choi et al., Buckner et al., and Yeo et al. We'll use the cortical
72+
% networks from Yeo et al. here.
73+
%
74+
75+
[bucknermaps, mapnames] = load_image_set('bucknerlab', 'noverbose'); % loads 7 masks from Yeo et al.
76+
disp(char(mapnames))
77+
78+
% Create a montage plot
79+
o2 = montage(get_wh_image(bucknermaps, 1), 'trans', 'compact2', 'color', rand(1, 3));
80+
for i = 2:7, o2 = addblobs(o2, region(get_wh_image(bucknermaps, i)), 'trans', 'color', rand(1, 3)); end
81+
drawnow, snapnow
82+
83+
%% Pain, Cognition, Emotion balanced N = 270 dataset
84+
%
85+
% This dataset is an fmri_data object class object created using CANlab tools (canlab.github.io).
86+
% It contains 270 single-participant fMRI contrast maps across 18 studies (with 15 participants per study).
87+
% Studies are grouped into three domains: Pain, Cognitive Control, and Negative Emotion, with 9 studies each.
88+
% Each domain includes 3 subdomains, with 3 studies each.
89+
%
90+
% The dataset is from Kragel et al. 2018, Nature Neuroscience.
91+
% It is too large for Github, and it's stored on Neurovault.org
92+
% as collection #504. You could get it using CANlab tools like this:
93+
%
94+
% |[files_on_disk, url_on_neurovault, mycollection, myimages] = retrieve_neurovault_collection(504);|
95+
%
96+
% It is also available on Figshare, with DOI 10.6084/m9.figshare.24033402
97+
% https://figshare.com/ndownloader/files/42143352
98+
%
99+
% If you download from Neurovault, you'd
100+
% have to add metadata for the study category labels to use it.
101+
% Therefore, we suggest you use the CANLab load_image_set() function, as below.
102+
% It saves a file on your hard drive the first time you run it:
103+
%
104+
% |kragel_2018_nat_neurosci_270_subjects_test_images.mat|
105+
%
106+
% This file also has metadata that is not necessarily on Neurovault.
107+
% If you save this file somewhere on your Matlab path, you'll be able to
108+
% reload and reuse the dataset easily.
109+
110+
[test_images, names] = load_image_set('kragel18_alldata', 'noverbose');
111+
112+
% This field contains a table object with metadata for each image:
113+
metadata = test_images.metadata_table;
114+
115+
disp('Metadata available in test_images.metadata_table:')
116+
metadata(1:5, :)
117+
118+
% Make a plot of the spatial correlation of the average image for each study
119+
120+
imgs = cellstr(test_images.image_names);
121+
m = mean(test_images);
122+
123+
for i = 1:length(names)
124+
125+
% Create a mean image for each study and store in "m" object.
126+
127+
wh = metadata.Studynumber == i;
128+
studymean = mean(get_wh_image(test_images, find(wh)));
129+
m.dat(:, i) = studymean.dat;
130+
131+
end
132+
133+
disp('Map of spatial correlations across the mean images for each study');
134+
135+
plot_correlation_matrix(m.dat, 'names', names, 'partitions', [ones(1, 6) 2*ones(1, 6) 3*ones(1, 6)], 'partitionlabels', {'Pain', 'Cognition', 'Emotion'});
136+
drawnow, snapnow
137+
138+
%% Pain across six intensity levels per person (BMRK3)
139+
%
140+
% The dataset contains data from 33 participants, with brain responses to six levels
141+
% of heat (non-painful and painful). Each image is the average over several
142+
% (4-8) trials of heat delivered at a single stimulus intensity, ranging
143+
% from 44.3 - 49.3 degrees C in one-degree increments. Each image is also
144+
% paired with an average reported pain value for that set of trials, rated
145+
% immediately after heat experience.
146+
%
147+
% This dataset is interesting for mixed-effects and predictive analyses, as
148+
% it has both within-person and between-person sources of variance.
149+
%
150+
% Aspects of this data appear in these papers:
151+
% Wager, T.D., Atlas, L.T., Lindquist, M.A., Roy, M., Choong-Wan, W., Kross, E. (2013).
152+
% An fMRI-Based Neurologic Signature of Physical Pain. The New England Journal of Medicine. 368:1388-1397
153+
% (Study 2)
154+
%
155+
% Woo, C. -W., Roy, M., Buhle, J. T. & Wager, T. D. (2015). Distinct brain systems
156+
% mediate the effects of nociceptive input and self-regulation on pain. PLOS Biology. 13(1):
157+
% e1002036. doi:10.1371/journal.pbio.1002036
158+
%
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
%% Using the atlas object for Region of Interest (ROI) analyses
2+
3+
%% About the atlas object
4+
% An atlas-class object is a specialized subclass of fmri_data that stores
5+
% information about a series of parcels, or pre-defined regions, and in
6+
% some cases the probalistic maps that underlie the final parcellation.
7+
%
8+
% Some common uses of atlas objects include:
9+
% * Labeling regions by best-matching atlas regions, as in region.table()
10+
% * Analysis within specific ROIs, or on ROI averages
11+
% * Defining regions for connectivity and graph theoretic analyses
12+
%
13+
% A list of pre-defined atlases is contained in the function |load_atlas|.
14+
% The default atlas for some CANlab functions is the "CANlab combined 2018"
15+
% This was created by Tor Wager from other published atlases. It includes:
16+
%
17+
% * Glasser 2016 Nature 180-region cortical parcellation (in MNI space, not indivdidualized)
18+
% * Pauli 2016 PNAS basal ganglia subregions
19+
% * Amygdala/hippocampal and basal forebrain regions from SPM Anatomy Toolbox
20+
% * Thalamus regions from the Morel thalamus atlas
21+
% * Subthalamus/Basal forebrain regions from Pauli "reinforcement learning" HCP atlas
22+
% * Diedrichsen cerebellar atlas regions
23+
% * Multiple named brainstem nuclei localized based on individual papers
24+
% * Additional Shen atlas parcels to cover areas (esp. brainstem) not otherwise named
25+
%
26+
% References for the corresponding papers are stored in the atlas object, and
27+
% printed in tables generated with the region.table() method.
28+
%
29+
% There are many methods for atlas, including all the fmri_data methods.
30+
% You can see those with |methods(atlas)|. For example:
31+
%
32+
% Using the |select_atlas_subset()| method:
33+
% You can select any subset of atlas regions by name or number, and return
34+
% them in a new atlas object. You can also 'flatten' regions, combining
35+
% them into a single new region.
36+
%
37+
% % Using the |extract_data()| method:
38+
% You can extract average data from every image in an atlas, for a series of target images.
39+
%
40+
% We will explore these here.
41+
42+
%% load an atlas
43+
% 'atlas' objects are a class of objects specially designed for brain
44+
% atlases. Here is more information on this class (also try |doc atlas|)
45+
46+
help atlas
47+
48+
% The function load_atlas in the CANlab toolbox loads a number of named
49+
% atlases included with the toolbox. Here is a list of named atlases:
50+
51+
help load_atlas
52+
53+
% Now load the "CANlab combined 2018" atlas:
54+
atlas_obj = load_atlas('canlab2018_2mm');
55+
56+
57+
%% visualize the atlas regions
58+
59+
orthviews(atlas_obj);
60+
61+
o2 = montage(atlas_obj);
62+
63+
drawnow, snapnow
64+
%% Selecting regions of interest
65+
% There are several ways of selecting regions of interest. You can do it:
66+
% * By name or part of name (in the .labels, .labels_2, or other fields)
67+
% * By number
68+
% * Graphically, or by entering a coordinate and a search radius
69+
70+
%%
71+
% *Select regions graphically or by coordinate*
72+
73+
% First bring up the orthviews display:
74+
orthviews(atlas_obj);
75+
76+
% Now click on a coordinate in the center of vmPFC
77+
% We'll use the SPM code below to do this here:
78+
79+
spm_orthviews('Reposition', [0 38 -11])
80+
81+
% Running this will create a subset atlas containing only regions with centers
82+
% within 20 mm of that coordinate.
83+
84+
[obj_within_20mm,index_vals] = select_regions_near_crosshairs(atlas_obj, 'thresh', 20);
85+
86+
orthviews(obj_within_20mm);
87+
drawnow, snapnow
88+
89+
% To reproduce this later in a script, you can enter the coordinates as
90+
% input instead:
91+
92+
[obj_within_20mm,index_vals] = select_regions_near_crosshairs(atlas_obj, 'coords', [0 38 -11], 'thresh', 20);
93+
94+
% This function returns index values, so you can use these directly to
95+
% specify the regions in select_atlas_subset as well.
96+
97+
find(index_vals)
98+
99+
test_obj = select_atlas_subset(atlas_obj, find(index_vals));
100+
101+
% % This should yield the same map of vmPFC regions: orthviews(test_obj)
102+
103+
%%
104+
% *Select regions by name*
105+
% Let's select all the regions in the thalamus. All regions are labeled in
106+
% the atlas object, so we can select them by name.
107+
108+
% Select all regions with "Thal" in the label:
109+
thal = select_atlas_subset(atlas_obj, {'Thal'})
110+
111+
% Print the labels:
112+
thal.labels
113+
114+
% Select a few thalamus/epithalamus regions of interest:
115+
thal = select_atlas_subset(atlas_obj, {'Thal_Intra', 'Thal_VL', 'Thal_MD', 'Thal_LGN', 'Thal_MGN', 'Thal_Hb'});
116+
thal.labels
117+
118+
% Select all the regions with "Thal" in the label, and collapse them into a single region:
119+
whole_thal = select_atlas_subset(atlas_obj, {'Thal'}, 'flatten');
120+
121+
%% Extract and analyze data from atlas regions
122+
%
123+
124+
%%
125+
% First, we'll load a dataset to extract data from for an ROI analysis
126+
% The dataset contains data from 33 participants, with brain responses to six levels
127+
% of heat (non-painful and painful).
128+
%
129+
% Aspects of this data appear in these papers:
130+
% Wager, T.D., Atlas, L.T., Lindquist, M.A., Roy, M., Choong-Wan, W., Kross, E. (2013).
131+
% An fMRI-Based Neurologic Signature of Physical Pain. The New England Journal of Medicine. 368:1388-1397
132+
% (Study 2)
133+
%
134+
% Woo, C. -W., Roy, M., Buhle, J. T. & Wager, T. D. (2015). Distinct brain systems
135+
% mediate the effects of nociceptive input and self-regulation on pain. PLOS Biology. 13(1):
136+
% e1002036. doi:10.1371/journal.pbio.1002036
137+
%

CanlabCore/Unit_tests/walkthroughs/private/canlab_help_2b_basic_image_visualization.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
% slices, so as to show the "whole picture" and not omit any results.
9393
%
9494
% You can customize this a lot, as it uses the fmridisplay() object class,
95-
% which allows you to add custom montages (in axial, saggital, and coronal
95+
% which allows you to add custom montages (in axial, sagittal, and coronal
9696
% orientations, add blobs of various types, and remove them and re-plot.
9797
% See |help fmridisplay| and |help fmridisplay.addblobs| for more details.
9898
%

CanlabCore/Unit_tests/walkthroughs/private/canlab_help_2c_loading_datasets.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
% (4-8) trials of heat delivered at a single stimulus intensity, ranging
143143
% from 44.3 - 49.3 degrees C in one-degree increments. Each image is also
144144
% paired with an average reported pain value for that set of trials, rated
145-
% immmediately after heat experience.
145+
% immediately after heat experience.
146146
%
147147
% This dataset is interesting for mixed-effects and predictive analyses, as
148148
% it has both within-person and between-person sources of variance.

CanlabCore/Unit_tests/walkthroughs/private/canlab_help_3b_atlases_and_ROI_analysis.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@
214214
%
215215
% With the pain dataset, for a real analysis we might worry that multiple
216216
% images come from the same subject. We can't do stats across all the
217-
% iamges without accounting for the correlations among images belonging to
218-
% the same subject. But first, let's plot the averages and see waht we get:
217+
% images without accounting for the correlations among images belonging to
218+
% the same subject. But first, let's plot the averages and see what we get:
219219

220220
% Concatenate the region averages into a matrix:
221221
roi_averages = cat(2, r.dat);
@@ -306,7 +306,7 @@
306306
% NAc = select_atlas_subset(atlas_obj, {'V_Str'});
307307
%
308308
% 2. try the t-test on 48 degree only images above. What do you see? Which
309-
% regions show sigificant activation?
309+
% regions show significant activation?
310310
%
311311
% 3. Try to identify which prefrontal regions show the greatest emotion
312312
% regulation effect, and which show the greatest response during pain.

CanlabCore/Unit_tests/walkthroughs/private/canlab_help_4b_3D_visualization.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@
105105
%%
106106
% You can see some prepackaged sets in |help canlab_results_fmridisplay|
107107
% These include:
108-
% 'full' Axial, coronal, and saggital slices, 4 cortical surfaces
109-
% 'compact' Midline saggital and two rows of axial slices [the default]
110-
% 'compact2' A single row showing midline saggital and axial slices
108+
% 'full' Axial, coronal, and sagittal slices, 4 cortical surfaces
109+
% 'compact' Midline sagittal and two rows of axial slices [the default]
110+
% 'compact2' A single row showing midline sagittal and axial slices
111111
% 'multirow' A series of 'compact2' displays in one figure for comparing different images/maps side by side
112112
% 'regioncenters' A series of separate axes, each focused on one region
113113
%

CanlabCore/Unit_tests/walkthroughs/private/canlab_help_5_regression_walkthrough.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
% Do a standard OLS regression and view the results:
368368
out = regress(image_obj_untouched, 'nodisplay');
369369

370-
% Treshold at q < .05 FDR and display
370+
% Threshold at q < .05 FDR and display
371371
t_untouched = threshold(out.t, .05, 'fdr');
372372

373373
o2 = montage(t_untouched);

0 commit comments

Comments
 (0)