Is there a way to retrieve physiological data from acqknowledge and preprocess them in R?

Viewed 31

I'm trying to retrieve raw physiological data (hand dynanometer) from Acqknowledge to be able to preprocess and analyze them in R (or Matlab) in an automatized way. Is there a way to do that ? I would like to avoid having to copy/paste the data manually from Acknowledge to Excel to read them in R.

Then I would like to apply a filter on the data and retrieve the squeezes of interest in R. Is there a way to do that ?

Any advice is very welcome, thank you in advance!

1 Answers

I had a similar problem. The key is the load_acq.m function, you can find it here -> https://github.com/munoztd0/fusy-octave-memories/blob/main/load_acq.m then you can just loop through them and save them as .csv or anything that you can load and work with in R.

As for how to do that I have put together a little routine to do that.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Create physiological files from AcqKnowledge
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% SETTING THE PATH
path = 'your path here'; %your path here
physiodir   = fullfile(path, '/SOURCE/physio');
outdir = fullfile(path, '/DERIVATIVES/physio');
session = "first" %your session

base = [path 'sub-**_ses-' session '*'];

subj = dir(base); %check all matching subject for this session

addpath([path '/functions']) % load aknowledge functions
%check here https://github.com/munoztd0/fusy-octave-memories/blob/main/load_acq.m

for i=1:length(subj)

cd (physiodir) %go to the folder

subjO = char(subj(i).name);
subjX =  subjO(end-3:end); %remove .mat extension
filename = [subjX '.acq']; %add .acq extension
                

disp (['****** PARTICIPANT: ' subjX ' **** session ' session ' ****' ]);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% OPEN FILE
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


physio = load_acq(filename); %load and transform acknowledge file

data = physio.data; %or whatever the name is




%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% CREATE AND SAVE THE CHANNEL
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



cd (outdir) %go to the folder

% save the data as a file text in the participant directory
fid = fopen([subjX ',txt'],'wt');
for ii = 1:length(data)
    fprintf(fid,'%g\t',data(ii));
    fprintf(fid,'\n');
end
fclose(fid);

end 

Hope it helps !

Related