Diff for "DumpDemographics" - MRC CBU Imaging Wiki
location: Diff for "DumpDemographics"
Differences between revisions 1 and 6 (spanning 5 versions)
Revision 1 as of 2009-12-11 12:47:09
Size: 913
Editor: RhodriCusack
Comment:
Revision 6 as of 2013-03-07 21:22:58
Size: 1187
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
% Dumps sexes and ages of a list of subjects, extracted from the DICOM files in /mridata/cbu
% Also produces mean +/- sd of ages across group
Line 8: Line 11:
age=[];
Line 11: Line 15:
        daydir=dir(fullfile(rawpath,fn(1).name,'2009*'));         daydir=dir(fullfile(rawpath,fn(1).name,'20*'));
Line 16: Line 20:
        H=spm_dicom_headers(dicomfn);
        fprintf('%s\t%s\n',H{1}.PatientsSex,H{1}.PatientsAge);
        age=[age str2num(H{1}.PatientsAge(1:end-1))];
Line 19: Line 26:
    H=spm_dicom_headers(dicomfn);
    fprintf('%s\t%s\n',H{1}.PatientsSex,H{1}.PatientsAge);
end;
Line 22: Line 28:
end; fprintf('Age %f +/- %f\n',mean(age),std(age));
        

Dump demographics

Here's a matlab script that dumps the age & sex of a list of subjects.

% Dumps sexes and ages of a list of subjects, extracted from the DICOM files in /mridata/cbu
% Also produces mean +/- sd of ages across group

subjs={'CBU090515','CBU090516','CBU090518','CBU090519','CBU090520','CBU090829','CBU090830','CBU090837','CBU090838','CBU090842'};
rawpath='/mridata/cbu';

age=[];
for subjind=1:length(subjs)
    fn=dir(fullfile(rawpath,[subjs{subjind} '*']));
    try
        daydir=dir(fullfile(rawpath,fn(1).name,'20*'));
        seriesdir=dir(fullfile(rawpath,fn(1).name,daydir(1).name,'Series*'));
        dicomfn=dir(fullfile(rawpath,fn(1).name,daydir(1).name,seriesdir(1).name,'*.dcm'));
        dicomfn=fullfile(rawpath,fn(1).name,daydir(1).name,seriesdir(1).name,dicomfn(1).name);
        fprintf('%s\t',subjs{subjind});
        H=spm_dicom_headers(dicomfn);
        fprintf('%s\t%s\n',H{1}.PatientsSex,H{1}.PatientsAge);
        age=[age str2num(H{1}.PatientsAge(1:end-1))];
    catch
            fprintf('Cannot find %s\n',subjs{subjind});
    end;
end;
    
fprintf('Age %f +/- %f\n',mean(age),std(age));

CbuImaging: DumpDemographics (last edited 2013-03-07 21:22:58 by localhost)