-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfnirsSaveData.m
26 lines (23 loc) · 1.51 KB
/
fnirsSaveData.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
%July 22nd 2024
%Ivy Hill
%This function saves the full fnirs data (after filtering it) and the
%easier to read mean/std of the data. These data are saved to both csv
%and mat files. Folders are procedurally generated for subjects.
%Edits made August 5th, 2024; August 6th, 2024
function fnirsSaveData(subjectData, subjectDataSimple, subject, con, directory)
loadBar = waitbar(0, "Saving Data"); %Creates a loading bar to track progress through function
warning off %removes error for if file already exists
statsPath = strcat(fullfile(directory, "Hb_Stats-fNIRS\"));
folderExist = mkdir(statsPath, strcat("subject_", subject, "\"));
warning on
waitbar(0.2);
save(strcat(statsPath, "subject_", subject, "\", "subject_", subject, "_", con, "_EpochData"), "subjectData"); %Saves all data as .mat
waitbar(0.4);
save(strcat(statsPath, "subject_", subject, "\", "subject_", subject, "_", con, "_EpochStats"), "subjectDataSimple"); %saves mean & std data as .mat once created
waitbar(0.6)
writetable(subjectData, strcat(statsPath, "subject_", subject, "\", "subject_", subject, "_", con, "_subjectData.csv")); %Saves all data as .csv (channels are laid out linearly with time (ie every 20 rows in the x direction is 1 timestep for 1 task for 1 stat (HbO / HbR)))
waitbar(0.8)
writetable(subjectDataSimple, strcat(statsPath, "subject_", subject, "\", "subject_", subject, "_", con, "_subjectDataSimple.csv")); %saves mean & std data as .csv once created
waitbar(1)
close(loadBar);
end