forked from KamitaniLab/GenericObjectDecoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexport_volume.m
More file actions
31 lines (25 loc) · 938 Bytes
/
Copy pathexport_volume.m
File metadata and controls
31 lines (25 loc) · 938 Bytes
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
% Export brain volume images
%
% This script requires BrainDecoderToolbox2 (https://github.com/KamitaniLab/BrainDecoderToolbox2).
%
% Change Log:
%
% 2019-01-15 Shuntaro Aoki <aoki@atr.jp>
%
% * Initial version.
%
clear all;
for i = 1:5
bdata_file = sprintf('./data/Subject%0d.mat', i);
template_file = sprintf('./data/Subject%0d_SpaceTemplate.nii', i);
output_file = sprintf('./data/Subject%0d_Func.nii', i);
[dataset, metadata] = load_data(bdata_file);
% Voxel data
voxel_data = get_dataset(dataset, metadata, 'VoxelData');
% Voxel xyz
voxel_x = get_metadata(metadata, 'voxel_x', 'RemoveNan', true);
voxel_y = get_metadata(metadata, 'voxel_y', 'RemoveNan', true);
voxel_z = get_metadata(metadata, 'voxel_z', 'RemoveNan', true);
% Exporting to .nii image (1st volume)
export_volumeimage(output_file, voxel_data(1, :), [voxel_x; voxel_y; voxel_z], template_file);
end