-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhcp_vis.m
41 lines (33 loc) · 1.16 KB
/
hcp_vis.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
%%%%%%%%
% Author: David Gruskin
% Contact: [email protected]
% Last updated: 03/2022
% Project: Brain connectivity at rest predicts individual differences in normative activity during movie watching
% Description: This code is called by restsync_main.m to create cifti files for visualization in HCP Workbench
% Dependencies: gifti toolbox from https://github.com/gllmflndn/gifti
%%%%%%%%
%%
function hcp_vis(wb_path,save_stem,write_vec,scalar_template,fname)
% Set paths
suffix = scalar_template(end-11:end);
% Save dscalars
if strcmp(suffix,'.dscalar.nii')
cii_scalar = ciftiopen(scalar_template, wb_path);
% map
for row = 1:length(write_vec)
cii_scalar.cdata(cii_scalar.cdata == row) = write_vec(row);
end
save_path = sprintf('%s/%s%s',save_stem,fname,suffix);
ciftisave(cii_scalar, save_path, wb_path)
end
% Save pscalars
if strcmp(suffix,'.pscalar.nii')
cii_scalar = ciftiopen(scalar_template, wb_path);
% map
for row = 1:length(write_vec)
cii_scalar.cdata(row,:) = write_vec(row);
end
save_path = sprintf('%s/%s%s',save_stem,fname,suffix);
ciftisave(cii_scalar, save_path, wb_path)
end
end