-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlotDVars.m
69 lines (64 loc) · 2.09 KB
/
PlotDVars.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function figDvarsComplete = PlotDVars(studyPath)
% PlotDVars(subjectDirectory)
%
% Description:
% Plots the DVars from the .vals file.
% If a directory is passed, then it is searhced for a single .vals file, or for an FCmaps directory containing a single .vals file.
%
% Usage:
% >> PlotDVars('C:\path\to\subj001\FCmaps\subj001_session_faln_dbnd_xr3d_atl_g7_bpss_resid.vals');
% >> PlotDVars('C:\path\to\subj001\FCmaps\');
% >> PlotDVars('C:\path\to\subj001\');
%
% Output:
% figDvarsComplete - figure handle
%
% Required Parameters:
% filename - The path to either a .vals file, the directory containing a single .vals file (e.g. FCmaps), or the subject/study directory containing the FCmaps files.
%
% Optional Parameters:
% none
%
% Author:
% Jarod L Roland
% Department of Neurosurgery
% Washington University School of Medicine in St. Louis
%
%% Parse params
if(exist(studyPath, 'file') == 2)
assert(strcmp(studyPath(end-4:end), '.vals'), 'Error: File must end in .vals');
filename = studyPath;
elseif(exist(studyPath, 'dir') == 7)
dirSearch = dir([studyPath '/*.vals']);
if(isempty(dirSearch) && exist([studyPath '/FCmaps'], 'dir') == 7)
studyPath = [studyPath '/FCmaps'];
dirSearch = dir([studyPath '/*.vals']);
end
filename = [studyPath '/' dirSearch(1).name];
if(length(dirSearch) > 1)
warning(['Warning: Multiple .vals files found, using the first one: ' filename]);
end
end
%% Load DVars
hFileDvar = fopen(filename);
assert(hFileDvar > 0, ['Error: Failed to open file: ' filename]);
dvars = textscan(hFileDvar, '');
dvars = dvars{1};
fclose(hFileDvar);
%% Plot
dvarsLims = [0 50];
numFrames = length(dvars);
figDvarsComplete = figure();
plot(dvars', 'color', [0.4 0.4 0.4]);
ylim(dvarsLims);
hold on
plot([0 numFrames], [5 5], 'k', 'linewidth', 0.5);
[~, file, ext] = fileparts(filename);
title([file ext], 'Interpreter', 'none');
ax = figDvarsComplete.CurrentAxes;
ax.XLim = [0 numFrames];
ax.YTick = [0 5 10:10:50];
ax.YTickLabels = {'0.0', '0.5', '1.0', '2.0', '3.0', '4.0', '5.0'};
ylabel('DVARS %');
xlabel('Frame');
end