星期四, 12月 21, 2006

Topic: 人體受外力牽拉後引發之姿勢反應_肌肉活化情形_rev.1

程式更新描述:
1. 將onset時間輸入方式改為由程式直接從已建立之excel檔案內擷取所需資料,不須經由對話窗輸入。
2. 新程式可同時讀取不同資料夾(依受試者ID不同做區別)內各個測試原始EMG data,並分別與該測試的onset時間資料相對應,如此可同時計算多位受試者以及多個測試的IEMG結果。
3. 將計算結果依每位受試者的測試順序做排序,俾輸出於指令窗中。

注意事項:
1. 實驗結果可儲存於任一路徑,若無指定路徑,則依預設路徑(D:\Physical Therapy\Graduate School\Thesis\Pilot study for Thesis\Data\Processed data for Matlab)進行原始資料之讀取。預設路徑內除了原始的實驗結果之外,亦須包括一Subject_information.txt檔案,紀錄欲分析之受試者ID,若欲分析不同受試者,則須由此檔案做變更。
2. 各個受試者的實驗結果以.xls檔案形式儲存於個別資料夾中(命名方式如,He01、He02、St05等;He/St代表不同受試者組別),各個受試者之資料夾中須包括所有測試的原始EMG data(命名方式如,He01C1V1R1、He02C1V2R3等;V代表不同牽拉干擾強度,R代表不同測試)以及onset時間檔案(Time events for EMG and pullonset signials.xls)

程式內容:

% IEMG4.m
% function: IEMG calculation for all trials of each subject
% onset data were retrived automatically
% the IEMG results were displayed on the command window
% raw_data: 1_Time(ms) 2_Fy 3_Mx 4_MGr 5_HAMr 6_PARAr 7_GMr 8_Pullonset
% range from (600ms prior to the pull onset) to (5000ms after the pull onset)
% baseline EMG:time interval between (500ms prior to the pull onset) to (150ms priot to the pull onset)
% IEMG:time interval between (150ms after the burst onset) to (500ms after the burst onset)

global EMGdata_path;
EMGdata_path = input('Please input the folder of the EMG data: [e.g.: D:\\Physical Therapy\\Graduate School\\Thesis\\Pilot study for Thesis\\Data\\Processed data for Matlab]','s');

if isempty(EMGdata_path)
EMGdata_path = 'D:\Physical Therapy\Graduate School\Thesis\Pilot study for Thesis\Data\Processed data for Matlab';
end

cd(EMGdata_path);
Subject_information = textread('Subject_information.txt','%s');
Subject_amount = size(Subject_information,1);


for i = 1:Subject_amount


Onsetdata_xls = xlsread([EMGdata_path,'\',Subject_information{i}(1:4),'\','Time events for EMG and pullonset signials.xls'],'B3:F14'); % [pullonset,MGronset,HAMronset,PARAronset,GMronset]
data_name=0;
Onsetdata=0;
IEMG=0;

fprintf('\n %s\n',Subject_information{i}(1:4))

for j = 1:4 % 4 perturbation amplitudes
for k = 1:3 % 3 trials
data_name = [Subject_information{i}(1:4),'C',num2str(1),'V',num2str(j),'R',num2str(k)];
if exist([EMGdata_path,'\',Subject_information{i}(1:4),'\',data_name,'.xls'])
data_name = [Subject_information{i}(1:4),'C',num2str(1),'V',num2str(j),'R',num2str(k)];
else
data_name = [Subject_information{i}(1:4),'C',num2str(1),'V',num2str(j),'R',num2str(k),'r'];
end
Onsetdata = Onsetdata_xls((j-1)*3+k,:);
raw_data = xlsread([EMGdata_path,'\',Subject_information{i}(1:4),'\',data_name,'.xls'],'C19:J5618');
baseline = mean(raw_data(101:451,4:7));

rawIEMG(1) = (1/2*(raw_data((Onsetdata(2)-Onsetdata(1)+149),4)+raw_data((Onsetdata(2)-Onsetdata(1)+499),4))+sum(raw_data((Onsetdata(2)-Onsetdata(1)+150):(Onsetdata(2)-Onsetdata(1)+498),4))); % unit:V*ms
rawIEMG(2) = (1/2*(raw_data((Onsetdata(3)-Onsetdata(1)+149),5)+raw_data((Onsetdata(3)-Onsetdata(1)+499),5))+sum(raw_data((Onsetdata(3)-Onsetdata(1)+150):(Onsetdata(3)-Onsetdata(1)+498),5))); % unit:V*ms
rawIEMG(3) = (1/2*(raw_data((Onsetdata(4)-Onsetdata(1)+149),6)+raw_data((Onsetdata(4)-Onsetdata(1)+499),6))+sum(raw_data((Onsetdata(4)-Onsetdata(1)+150):(Onsetdata(4)-Onsetdata(1)+498),6))); % unit:V*ms
rawIEMG(4) = (1/2*(raw_data((Onsetdata(5)-Onsetdata(1)+149),7)+raw_data((Onsetdata(5)-Onsetdata(1)+499),7))+sum(raw_data((Onsetdata(5)-Onsetdata(1)+150):(Onsetdata(5)-Onsetdata(1)+498),7))); % unit:V*ms

IEMG= rawIEMG-baseline; % [rMG rHAM rPARA rGM]

fprintf(' %s\t %f\t %f\t %f\t %f\n',data_name,IEMG(1),IEMG(2),IEMG(3),IEMG(4))
end % for k loop
end % for j loop
end % for i loop

執行結果:



討論:
1. 目前程式內容,僅限於將計算結果輸出於指令窗中,待完成部分包括:(1)將各個trial之IEMG計算值和每3個trial之平均值和標準差(代表各個牽拉強度)之執行結果以excel檔案形式輸出並儲存於特定資料夾中。
(2) 選出欲代表的EMG活化圖形之trial(以對話方式進行),並將圖形輸出且儲存於既定資料夾內

沒有留言: