forked from m053m716/-io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_block_simulation.m
51 lines (48 loc) · 1.7 KB
/
load_block_simulation.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
42
43
44
45
46
47
48
49
50
51
function F = load_block_simulation(SUBJ, YYYY, MM, DD, BLOCK)
%LOAD_BLOCK_SIMULATION Loads simulated field data associated with a given experimental block.
%
% Syntax:
% F = io.load_block_simulation(SUBJ, YYYY, MM, DD, BLOCK)
%
% Example:
% F = io.load_block_simulation('Frank', 2021, 11, 18, 97);
% % This would return a struct with simulated field values for Frank
% % 2021-11-18 block 97.
%
% Inputs:
% SUBJ - String: should be name of subject (e.g. "Rupert" or "Frank")
% YYYY - year (numeric scalar)
% MM - month (numeric scalar)
% DD - day (numeric scalar)
% BLOCK - Recording block index (numeric scalar)
%
% Output:
% F - Struct with data related to field simulation/visualization.
% Specifically, the fields:
% - .X X-Meshgrid at which values were computed
% - .Y Y-Meshgrid at which values were computed
% - .Z Actual current density values from simulation
%
% See also: Contents
if numel(BLOCK) > 1
F = cell(numel(BLOCK), 1);
for iB = 1:numel(BLOCK)
F{iB, 1} = io.load_block_simulation(SUBJ, YYYY, MM, DD, BLOCK(iB));
end
return;
end
[yyyy, mm, dd] = utils.parse_date_args(YYYY, MM, DD);
if ~isnumeric(BLOCK)
BLOCK = str2double(BLOCK);
end
gen_data_loc = parameters('generated_data_folder');
tank = sprintf('%s_%04d_%02d_%02d', SUBJ, yyyy, mm, dd);
block = sprintf('%s_%d', tank, BLOCK);
in_files = dir(fullfile(gen_data_loc, SUBJ, tank, num2str(BLOCK), sprintf('%s_Simulated_Field.mat', block)));
if isempty(in_files)
F = [];
warning('No simulated field data for <strong>%s</strong>.\n\t\t->\tDid you run `export_specific_simulation` for that block yet?\n', block);
return;
end
F = load(fullfile(in_files(1).folder, in_files(1).name));
end