romainVala / matvol

batch scripting files for neuroimaging
Apache License 2.0
4 stars 5 forks source link

add function to seperate if run have complet physio or not #82

Closed benoitberanger closed 2 years ago

benoitberanger commented 2 years ago

the code is done, need to wrap it in a function

benoitberanger commented 2 years ago

its not realistic to have a userfriendly function, since this involves many regex that have to be mannualy defined but here is a snippet :

run_all = e.getSerie('run').removeEmpty();

%--------------------------------------------------------------------------
% in AFNI, outside the mask is NaN
% in SPM, outise the mask is 0
% so convert NaN to 0

clear par
if CLUSTER
    par.run = 0;
    par.sge = 1;
    par.sge_queu = 'normal,bigmem'; 
else
    par.run = 1;
    par.sge = 0;
end
job_afni_remove_nan( run_all.getVolume('^wts_OC'), par );
%--------------------------------------------------------------------------

% get physio files & check if some are missing
info = e.getSerie('phy').getPhysio('info');   info = info(:);   missing_info = cellfun( 'isempty', info(:).getPath() );
puls = e.getSerie('phy').getPhysio('puls');   puls = puls(:);   missing_puls = cellfun( 'isempty', puls(:).getPath() );
resp = e.getSerie('phy').getPhysio('resp');   resp = resp(:);   missing_resp = cellfun( 'isempty', resp(:).getPath() );

idx_missing = missing_info | missing_puls | missing_resp;
idx_ok      = ~idx_missing;

run_phy_missing = run_all( idx_missing );
run_phy_ok      = run_all( idx_ok );

volume_phy_ok = run_phy_ok.getVolume('^nwts_OC');
outdir_phy_ok = volume_phy_ok.getDir();
rp_phy_ok     = run_phy_ok.getRP('rp_spm');
mask_phy_ok   = run_phy_ok.getExam().getSerie('anat').getVolume('^rwp[23]');
info_ok       = info( idx_ok );
puls_ok       = puls( idx_ok );
resp_ok       = resp( idx_ok );

volume_phy_missing = run_phy_missing.getVolume('^nwts_OC');
outdir_phy_missing = volume_phy_missing.getDir();
rp_phy_missing     = run_phy_missing.getRP('rp_spm');
mask_phy_missing   = run_phy_missing.getExam().getSerie('anat').getVolume('^rwp[23]');
% info_missing       = info( idx_missing );
% puls_missing       = puls( idx_missing );
% resp_missing       = resp( idx_missing );