-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreate_AllPatients.m
36 lines (27 loc) · 1.32 KB
/
Create_AllPatients.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
% Create AllPatients by combining the surveys
clc;clear all;
load DailyPromptSurvey_Augmented;
load WeeklyPromptSurvey;
% let us recode the patient IDs for easy reference
Patient.ID = 1:length(unique(DailyPromptSurvey.healthCode));
Patient.HealthCode = unique(DailyPromptSurvey.healthCode);
numPatients = length(Patient.ID);
for kp = 1:numPatients
if mod(kp,500)==0
disp(['Processing Record Number: ',num2str(kp),' out of ',num2str(numPatients)]);
end
AllPatients.ID(kp,1)=Patient.ID(kp);
% get all the records for each patient
I_DS = find(DailyPromptSurvey.healthCode == Patient.HealthCode(kp)); % daily survey
I_WS = find(WeeklyPromptSurvey.healthCode == Patient.HealthCode(kp)); % weekly survey
% assign the records in the new structure
AllPatients.DailySurvey{kp,1} = DailyPromptSurvey(I_DS,:);
AllPatients.DailySurveySize(kp,1) = length(I_DS);
AllPatients.WeeklySurvey{kp,1} = WeeklyPromptSurvey(I_WS,:);
AllPatients.WeeklySurveySize(kp,1) = length(I_WS);
AllPatients.PeakFlowSize(kp,1) = length(find(~isnan(DailyPromptSurvey.peakflow(I_DS))));
end
% (optional) save AllPatients - large file (around 20 GB)
% save('AllPatients.mat','AllPatients','-v7.3');
clc;
disp(['Finished processing ', num2str(numPatients),' patients']);