-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
246,908 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
%% Data analysis of participants in Guangzhou (gz) | ||
clear | ||
clc | ||
emerge=cell(29,3); | ||
for n=1:29 | ||
load('data_path'); | ||
j=1; | ||
k=1; | ||
for i=2:161 | ||
if strcmp(stor_var{i,5},'CORRECT')==1 | ||
j=j+1; | ||
else | ||
k=k+1; | ||
end | ||
end | ||
emerge1={}; | ||
emerge2=[]; | ||
a=1; | ||
b=1; | ||
c=1; | ||
if j>k | ||
for i=2:161 | ||
if (strcmp(stor_var{i,4},'TIMEOUT') == 0) && (strcmp(stor_var{i,5},'CORRECT') == 1) | ||
emerge1{a,1}=stor_var{i,6}; | ||
a=a+1; | ||
end | ||
end | ||
else | ||
for i=2:161 | ||
if (strcmp(stor_var{i,4},'TIMEOUT') == 0) && (strcmp(stor_var{i,5},'WRONG') == 1) | ||
emerge1{a,1}=stor_var{i,6}; | ||
a=a+1; | ||
end | ||
end | ||
end | ||
emerge1=cell2mat(emerge1); | ||
for i=1:length(emerge1) | ||
if (emerge1(i,1)>=(mean(emerge1(:,1))-3.*std(emerge1(:,1)))) && (emerge1(i,1)<=(mean(emerge1(:,1))+3.*std(emerge1(:,1)))) | ||
emerge2(b,1)=emerge1(i,1); | ||
b=b+1; | ||
end | ||
end | ||
emerge{n,1}=n; | ||
emerge{n,2}=length(emerge1)./160; | ||
emerge{n,3}=median(emerge2(:,1)); | ||
end | ||
savepath = strcat('filesave_path'); | ||
save(savepath,'emerge'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
clc; | ||
clear; | ||
main_path = 'D:\paper2\paper3\心脏周期(代码)'; | ||
rr_path = 'RR'; | ||
mark_path = 'mark'; | ||
behav_path = 'behavior'; | ||
ecg_path = 'amp_clean'; | ||
r_tpath = 'R_T'; | ||
file = {'guangzhou','xizang'}; | ||
fs = 200; | ||
for i = 1:length(file) | ||
filert = dir(fullfile(main_path,r_tpath,file{i})); | ||
for j = 3:length(filert) | ||
sys_dys=[]; | ||
% rt = load(fullfile(main_path,r_tpath,file{i},filert(j).name)); | ||
rt = load(fullfile(main_path,r_tpath,'xizang',filert(j).name)); | ||
rt = rt(:,1)-39;%time delay 39 sampling | ||
% rt = rt(:,1)*200*60-39;%time delay 39 sampling | ||
sub = filert(j).name(1:length(filert(j).name)-4); | ||
mark = xlsread(fullfile(main_path,mark_path,file{i},[sub,'.xlsx'])); | ||
data_delay = load(fullfile(main_path,ecg_path,file{i},filert(j).name)); | ||
data = data_delay(1:size(data_delay,1)); | ||
behave = load(fullfile(main_path,behav_path,file{i},['stor_var',sub,'.mat'])); | ||
for h = 1:size(mark,1)/2 | ||
R_near = max(find(rt(:,1)/(60*fs)<(mark(h*2-1,1)))); | ||
ecgpos1 = rt(R_near,1); | ||
RRint = rt(R_near+1)-rt(R_near); | ||
plot(rt(R_near):rt(R_near+1),data(rt(R_near):rt(R_near+1)),'k') | ||
ecgpos2 = ecgpos1+RRint-12; | ||
%twave = data(ecgpos1+28:ecgpos2,:); | ||
twave = data(ecgpos1+28:ecgpos2,:); | ||
% hold on | ||
% plot(ecgpos1+28:ecgpos2,twave,'r') | ||
if (RRint-28)/3 <= size(twave,1) % from xizang 4.mat start | ||
tmaxpos = find(twave(1:((RRint-28)/3),1)==max(twave(1:((RRint-28)/3),1))); | ||
c=0; | ||
else | ||
tmaxpos = find(twave(1:size(twave,1),1)==max(twave(1:size(twave,1),1))); | ||
c=1; | ||
end | ||
twave2 = twave(tmaxpos:size(twave,1),:); | ||
hold on | ||
plot(ecgpos1+28+tmaxpos-1:ecgpos2,twave2,'g') | ||
dp = 0.12*fs; | ||
if dp > size(twave,1) | ||
xm = find(diff(twave2(:,1))==min(diff(twave2(:,1)))); | ||
else | ||
if dp < length(twave2) | ||
xm = find(diff(twave2(1:dp,1))==min(diff(twave2(1:dp,1)))); | ||
a=0; | ||
else | ||
xm = find(diff(twave2(1:length(twave2),1))==min(diff(twave2(1:length(twave2),1)))); | ||
a=1; | ||
end | ||
end | ||
ym = twave2(xm,1); | ||
xr = 16+xm; | ||
if xr > length(twave2) | ||
xr = length(twave2); | ||
b=0; | ||
else | ||
xr = xr; | ||
b=1; | ||
end | ||
xseq = xm:xr; | ||
yseq = twave2(xm:xr,1); | ||
x_tend = trapez_area(xm, ym, xseq, yseq, xr); | ||
nextR=rt(R_near+1)-0.8; | ||
syslen = 28+tmaxpos+x_tend; | ||
sys_dp = ecgpos1:ecgpos1+syslen-1; | ||
hold on | ||
plot(ecgpos1:ecgpos1+28+tmaxpos+x_tend,data(ecgpos1:ecgpos1+28+tmaxpos+x_tend),'b') | ||
hold on | ||
plot(rt(R_near+1)-syslen:rt(R_near+1),data(rt(R_near+1)-syslen:rt(R_near+1)),'r') | ||
dias_dp = (nextR-syslen):(nextR-0.08); | ||
%diastole_ecg=data(diastole_dp,:); | ||
if (mark(h*2-1,1))*60*fs <= ecgpos1+syslen-1 | ||
sys_dys(h,1) = behave.stor_var{h+1,6}; | ||
sys_dys(h,2) = 1; | ||
else | ||
if ecgpos1+syslen-1 < nextR-syslen && (mark(h*2-1,1))*60*fs < nextR-syslen | ||
sys_dys(h,1) = behave.stor_var{h+1,6}; | ||
sys_dys(h,2) = 2; | ||
elseif ecgpos1+syslen-1 >= nextR-syslen || (mark(h*2-1,1))*60*fs >= nextR-syslen | ||
sys_dys(h,1) = behave.stor_var{h+1,6}; | ||
sys_dys(h,2) = 3; | ||
end | ||
end | ||
sys_dys(h,3)= syslen/RRint; | ||
sys_dys(h,4)= syslen; | ||
sys_dys(h,5)= RRint; | ||
sys_dys(h,6)= a; | ||
sys_dys(h,7)= b; | ||
sys_dys(h,8)= c; | ||
end | ||
savepath=fullfile(main_path,'cardic2',[sub,'.mat']); | ||
save(savepath,'sys_dys') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import pandas as pd | ||
import numpy as np | ||
import hddm | ||
from scipy import stats | ||
import seaborn as sns | ||
import matplotlib.pyplot as plt | ||
import pymc | ||
import kabuki | ||
|
||
data = hddm.load_csv('rtgz.csv') | ||
#data = hddm.utils.flip_errors(data) | ||
fig = plt.figure() | ||
ax = fig.add_subplot(111, xlabel='RT', ylabel='count', title='RT distributions') | ||
for i, subj_data in data.groupby('subj_idx'): | ||
subj_data.rt.hist(bins=20, histtype='step', ax=ax) | ||
|
||
datana=data.dropna(axis=0,how='any') | ||
m_exp = hddm.HDDM(datana) | ||
m_exp.find_starting_values() | ||
m_exp.sample(10000, burn=1000) | ||
|
||
stats_exp = m_exp.gen_stats() | ||
stats_exp.to_csv('stats_gz.csv') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
clear; | ||
clc; | ||
mainfile = 'mainfile_path'; | ||
file = dir(fullfile(mainfile,'qrs_path')); | ||
filevent = dir(fullfile(mainfile,'rt_path')); | ||
|
||
for i = 1:length(file) | ||
rr=[]; | ||
a = 1; | ||
data = load(fullfile(mainfile,'qrs_data_path')); | ||
sub = file(i,1).name(1:length(file(i,1).name)-4); | ||
load([mainfile,'rt_data_path']); | ||
load([mainfile,'event_data_path']); | ||
lung = length(trg); | ||
d = 1; | ||
e = 1; | ||
for h = 2:size(stor_var,1) | ||
if strcmp(stor_var{h,5},'CORRECT')==1 | ||
d=d+1; | ||
elseif strcmp(stor_var{h,5},'WRONG')==1 | ||
e=e+1; | ||
end | ||
end | ||
b = 1; | ||
for j = 2:length(stor_var) | ||
if d > e && strcmp(stor_var{j,5},'CORRECT')==1 | ||
trg(b,2)= stor_var{j,6}; | ||
b= b+1; | ||
elseif d <= e && strcmp(stor_var{j,5},'WRONG')==1 | ||
trg(b,2)= stor_var{j,6}; | ||
b= b+1; | ||
end | ||
end | ||
for h = 1:lung | ||
R_near = max(find(data(:,1)<trg(h,1))); | ||
if (R_near+4) < length(data) && 0 <(R_near-3) | ||
rr(a,1) = data(R_near-2)-data(R_near-3); | ||
rr(a,2) = data(R_near-1)-data(R_near-2); | ||
rr(a,3) = data(R_near)-data(R_near-1); | ||
rr(a,4) = data(R_near+1)-data(R_near); | ||
rr(a,5) = data(R_near+2)-data(R_near+1); | ||
rr(a,6) = data(R_near+3)-data(R_near+2); | ||
rr(a,7) = trg(h,2); | ||
rr(a,8) = log10(trg(h,2)); | ||
rr(a,9) = str2num(sub); | ||
a = a+1; | ||
end | ||
end | ||
rrm(i-2,1) = mean(rr(:,1)); | ||
rrm(i-2,2) = mean(rr(:,2)); | ||
rrm(i-2,3) = mean(rr(:,3)); | ||
rrm(i-2,4) = mean(rr(:,4)); | ||
rrm(i-2,5) = mean(rr(:,5)); | ||
rrm(i-2,6) = mean(rr(:,6)); | ||
rrm(i-2,7) = str2num(sub); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
function outp2=diff2(vec) | ||
for i = 2:size(vec,1) | ||
outp2(i-1,1)= vec(i,1)-vec(i-1); | ||
end | ||
end |
Oops, something went wrong.