JiscMail Logo
Email discussion lists for the UK Education and Research communities

Help for SPM Archives


SPM Archives

SPM Archives


SPM@JISCMAIL.AC.UK


View:

Message:

[

First

|

Previous

|

Next

|

Last

]

By Topic:

[

First

|

Previous

|

Next

|

Last

]

By Author:

[

First

|

Previous

|

Next

|

Last

]

Font:

Monospaced Font

LISTSERV Archives

LISTSERV Archives

SPM Home

SPM Home

SPM  April 2009

SPM April 2009

Options

Subscribe or Unsubscribe

Subscribe or Unsubscribe

Log In

Log In

Get Password

Get Password

Subject:

Questions to transformation into MNI space (Colin standard)

From:

"C. Vehlow" <[log in to unmask]>

Reply-To:

C. Vehlow

Date:

Thu, 30 Apr 2009 13:52:19 +0100

Content-Type:

multipart/mixed

Parts/Attachments:

Parts/Attachments

text/plain (51 lines) , TransformationToColin.m (585 lines)

Hello,

I'm actually working with spm and got a script, that uses several spm
methods to transform anatomical and functional MR images into the MNI
space (Colin-Standard). This transformation is done on Dicom images,
which are transformed to Analyze format. This is done via loading
different workspaces after each other and using the spm_jobman method to
run the method. A rough sequence looks like this:

%Convertation from Dicoms
load se_convert.mat;....
spm_jobman('run',jobs)
%realignment of EPI data
load se_realign.mat....
spm_jobman('run',jobs)
%EPI Realignment
load se_mean.mat ....
spm_jobman('run',jobs)
%Coregistration T1 -> mean EPI
load se_coregister.mat;...
spm_jobman('run',jobs)
%Coregistration mean EPI -> MNI
load se_coregisterToMNI.mat;...
spm_jobman('run',jobs)
% Normalise
load se_segment.mat;
spm_jobman('run',jobs)
load se_normalise.mat

(I've also attached the whole script, calling all the methods)

If we use now some other Analyze files as input than those calculated
from Dicom, the outputs are horribly distorted. As it is hard to look
into the routines and reconstruct what is happing internally, some
questions about the functionality of the transformation occurred:

Which header information (regarding the analyze file) is required for
the transformation?
Is it the transformation based on the functional images and is the same
transformation just applied on the anatomical data?
Or would it also be possible to just transfer the anatomical images?
Because we've not found a way so far.
Is there a homogeneity correction included at some step of the
transformation?

I hope someone can help me and answer the one or the other question!

Thanks a lot
Corinna Vehlow


function TransformationToColin()

clear, clc
% set(0,'RecursionLimit',2000);

global defaults; spm_defaults

success = 0;

% All flags switched by 0 / 1
doDICOM = 0; %1 % DICOM conversion (EPI, wholebrains and T1)
doDelete = 0; %1 % delete dummies CAVE: files are irreversibly deleted and counted by available files (-> don't run twice!)
deleteDummies = 0; % CAVE (1), files are irreversibly deleted; CAVE (2) count by available files (-> don't run twice!)
                                       % only if DicomMethod run before
doMeanWholeBrain = 0; % Create mean of additional wholebrain EPIs (only executed if wholeEPI is not {}
                                       % -> Nur n�tig, wenn bei part-brain coverage zus�tzlich einige full-brain aufnahmen f�r die normalisierung aufgenommen wurden
doRealign = 0;%1 % Realignment der EPI-Daten
doMean = 0;%1 % EPI realignemnt --> Erstellt das mean EPI aus den realignten EPIs
doCoreg = 0;%1 % Coregister T1 -> mean EPI
doCoregMNI = 0;%1 % Coregister mean EPI -> MNI; Affine voranpassung in den MNI space, macht die unified segmentation robuster
doNormalise = 1;%1 % Normalise using unified segmentation (following initial affine coregistration into prior space for robstness)
                                       % Berechnen der Normalisierungsvorschrift mittels unified segmentation
doWrite = 0;%1 % Write normalised EPIs, mean EPI and T1; Anwenden der Normalisierung
doMove = 0;%1 % Sorts the normalised files in the correct directories
doSmooth = 0 ; % Smooth EPI images
FWHM = 8;

%---Ordner f�r die einzelnen Daten
paths = {'Orig'; 'Normalised'; ['Smooth_' int2str(FWHM) 'mm']}; % Should stay like this
subjects = struct([]); % Separated by komma or semicolon
runs = {'1';'2';'3';'4';'5'}; % Separated by komma or semicolon
structurals = {'3D'}; % {} for none
wholeEPI = {}; % {} for none Characterarray with foldernames for Dicomdata
%---Pfade f�r die Daten setzen----
numP = 1;
set =1;
while set
    dp = uigetdir; %('Select the data folder');
    if dp==0
        set = 0;
    else
        l = length(dp);
        for i=l:-1:1
            if (strcmp(dp(i),filesep)==1)
                subjects{numP}=dp(i+1:l);
                datapath{numP}=dp(1:i);
                break;
            end
        end
        numP = numP+1;
    end
end

% Waitbar initialisieren
maxWait = numel(subjects)*(9+2); %Objektanzahl*Methodenanzahl
actWait = 0;
wb = waitbar(actWait, 'Please wait...the process will take some time!');
   
%------Durchlaufe alle Datens�tze-----------------
for sub = 1:numel(subjects) % numel(A) returns the number of elements, n, in array A

    if doDICOM
        waitbar(actWait,wb,'Please wait...Dicom conversion!');
        
        % ---------- DICOM conversion --------------------
        for ses =1:numel(runs)
            if exist([datapath{sub} subjects{sub} filesep 'DICOM' filesep paths{1} filesep runs{ses}])==7
                try
                    load se_convert.mat;
                    [Files, Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep 'DICOM' filesep paths{1} filesep runs{ses}], '*.*');
                    Files = [repmat([datapath{sub} subjects{sub} filesep 'DICOM' filesep paths{1} filesep runs{ses} filesep],size(Files,1),1) Files];
                    for file = 1:size(Files,1)
                        jobs{1,1}.util{1,1}.dicom.data{file,1} = [Files(file,:)];
                    end
                    % Orig\run{ses} wird erstellt
                    mkdir([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}]);
                    jobs{1,1}.util{1,1}.dicom.outdir = {[datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}]};
                    % wholeEPI{ses} = runs{ses};
                    spm_jobman('run',jobs)
                end
            end
        end

        if numel(wholeEPI)>0
            load se_convert.mat;
            mkdir([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1}]);
            [Files, Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep 'DICOM' filesep paths{1} filesep wholeEPI{1}],'*.*');
            Files = [repmat([datapath{sub} subjects{sub} filesep 'DICOM' filesep paths{1} filesep wholeEPI{1} filesep],size(Files,1),1) Files];
            for file = 1:size(Files,1)
                jobs{1}.util{1}.dicom.data{file,1} = [Files(file,:)];
            end
            jobs{1}.util{1}.dicom.outdir = {[datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1}]};

            spm_jobman('run',jobs)
        end

        if numel(structurals)>0

            load se_convert.mat;
            % 3D Ordner wird erstellt
            mkdir([datapath{sub} subjects{sub} filesep structurals{1}]);

            [datapath{sub} subjects{sub} filesep 'DICOM' filesep structurals{1}]

            [Files, Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep 'DICOM' filesep structurals{1}], '*.*');
            Files = [repmat([datapath{sub} subjects{sub} filesep 'DICOM' filesep structurals{1} filesep],size(Files,1),1) Files];
            jobs{1}.util{1}.dicom.data = {};
            for file = 1:size(Files,1)
                jobs{1}.util{1}.dicom.data{file,1} = [Files(file,:)];
            end
            jobs{1}.util{1}.dicom.outdir = {[datapath{sub} subjects{sub} filesep structurals{1}]};
            spm_jobman('run',jobs)
        end
    end


    if doDelete
        actWait = actWait+(1/maxWait);
        waitbar(actWait,wb,'Please wait...deleting dummies!');
        
        % ---------- Delete Dummys --------------------
        for ses =1:numel(runs)
            if exist([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}])==7
                try
                    [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}],'*.img');
                    Files = [repmat([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep],size(Files,1),1) Files];
                    for ex = 1:deleteDummies
                        delete(Files(ex,:))
                        delete([Files(ex,1:end-3) 'hdr'])
                    end
                end
            end
        end
        if numel(wholeEPI)>0
            [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1}],'*.img');
            Files = [repmat([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1} filesep],size(Files,1),1) Files];
            for ex = 1:deleteDummies
                delete(Files(ex,:))
                delete([Files(ex,1:end-3) 'hdr'])
            end
        end
    end



    if doMeanWholeBrain && numel(wholeEPI)>0
        load se_realign.mat
        jobs{1}.spatial{1}.realign{1}.estwrite.data = {};
        [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1}],'*.img');
        Files = [repmat([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1} filesep],size(Files,1),1) Files];
        for file = 1:size(Files,1)
            jobs{1}.spatial{1}.realign{1}.estwrite.data{1}(file,:) = [Files(file,:) ',1'];
        end
        spm_jobman('run',jobs)
    end


    if doRealign
        actWait = actWait+(1/maxWait);
        waitbar(actWait,wb,'Please wait...Realignment der EPI-Daten!');
        
        % ---------- Realign --------------------
        load se_realign.mat
        jobs{1}.spatial{1}.realign{1}.estwrite.data = {};

        if numel(wholeEPI)>0
            jobs{1}.spatial{1}.realign{1}.estwrite.eoptionsrtm = 0;
            mepi = dir([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1} filesep 'mean*.img']);
            mEPI = [datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1} filesep mepi(1).name]
            jobs{1}.spatial{1}.realign{1}.estwrite.data{1}(1,:) = mEPI;

            for ses =1:numel(runs)
                if exist([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}])==7
                    try
                        [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}],'*.img');
                        Files = [repmat([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep],size(Files,1),1) Files];
                        for file = 1:size(Files,1)
                            jobs{1}.spatial{1}.realign{1}.estwrite.data{ses+1}(file,:) = [Files(file,:) ',1'];
                        end
                    end
                end
            end

            spm_jobman('run',jobs)

            mEPI = dir([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1} filesep 'mean*.img'])
            movefile([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1} filesep mEPI.name],...
                [datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.img'])
            movefile([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1} filesep mEPI.name(1:end-3) 'hdr'],...
                [datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.hdr'])


            delete([datapath{sub} subjects{sub} filesep paths{1} filesep wholeEPI{1} filesep 'mean*.*'])
                 
        else
            for ses =1:numel(runs)
                if exist([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}])==7
                    try
                        [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}],'*.img');
                        Files = [repmat([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep],size(Files,1),1) Files];
                        for file = 1:size(Files,1)
                            jobs{1}.spatial{1}.realign{1}.estwrite.data{ses}(file,:) = [Files(file,:) ',1'];
                        end
                    end
                end
            end
            spm_jobman('run',jobs)
            
            for ses =1:numel(runs)
                if exist([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}])==7
                    try
                        mEPI = dir([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep 'mean*.img']);
                        movefile([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep mEPI.name],...
                            [datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.img'])
                        movefile([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep mEPI.name(1:end-3) 'hdr'],...
                            [datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.hdr'])
                    end
                end
            end

        end


    end


    
    if doMean
        actWait = actWait+(1/maxWait);
        waitbar(actWait,wb,'Please wait...EPI Realignment!');
        
        load se_mean.mat
        jobs{1}.spatial{1}.realign{1}.write.data = {};
        for ses =1:numel(runs)
            if exist([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}])==7
                try
                    [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}],'*.img');
                    Files = [repmat([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep],size(Files,1),1) Files];
                    for file = 1:size(Files,1)
                        jobs{1}.spatial{1}.realign{1}.write.data{ses}(file,:) = [Files(file,:) ',1'];
                    end
                end
            end
        end
        spm_jobman('run',jobs)

        for ses =1:numel(runs)
            if exist([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}])==7
                try
                    mEPI = dir([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep 'mean*.img']);
                    movefile([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep mEPI.name],...
                        [datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.img'])
                    movefile([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep mEPI.name(1:end-3) 'hdr'],...
                        [datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.hdr'])
                end
            end
        end

    end



    if doCoreg
        actWait = actWait+(1/maxWait);
        waitbar(actWait,wb,'Please wait...Coregistration T1 -> mean EPI!');
        
        % ---------- Coregister T1 -> meanEPI --------------------
        load se_coregister.mat;
        jobs{1}.spatial{1}.coreg{1}.estimate.eoptions.sep = [4 2];
        [source,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep structurals{1}],'*.img');
        jobs{1}.spatial{1}.coreg{1}.estimate.source = {[datapath{sub} subjects{sub} filesep structurals{1} filesep source]};
        jobs{1}.spatial{1}.coreg{1}.estimate.ref = {[datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.img']};

        jobs{1}.spatial{1}.coreg{1}.estimate.source
        jobs{1}.spatial{1}.coreg{1}.estimate.ref

        spm_jobman('run',jobs)
    end


    if doCoregMNI
        actWait = actWait+(1/maxWait);
        waitbar(actWait,wb,'Please wait...Coregistration mean EPI -> MNI!');
        
        % ---------- Affine registration into MNI space --------------------
        load se_coregisterToMNI.mat;
        jobs{1}.spatial{1}.coreg{1}.estimate.other = {};
        cnt = 1;
        [source,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep structurals{1}],'*.img');
        jobs{1}.spatial{1}.coreg{1}.estimate.source = {[datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.img']};
        jobs{1}.spatial{1}.coreg{1}.estimate.ref = {defaults.segment.estimate.priors(1,:);};
        for ses =1:numel(runs)
            if exist([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}])==7
                try
                    [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}],'*.img');
                    Files = [repmat([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep],size(Files,1),1) Files];
                    for file = 1:size(Files,1)
                        jobs{1}.spatial{1}.coreg{1}.estimate.other{cnt,1} = [Files(file,:) ',1'];
                        cnt = cnt+1;
                    end
                end
            end
        end
        jobs{1}.spatial{1}.coreg{1}.estimate.other{cnt,1} = [datapath{sub} subjects{sub} filesep structurals{1} filesep source];

        spm_jobman('run',jobs)
    end

    if doNormalise
        actWait = actWait+(1/maxWait);
        waitbar(actWait,wb,'Please wait...Normalisation!');

        % ---------- Normalise using unified segmentation -----
        load se_segment.mat;
        jobs{1}.spatial{1}.preproc.opts.tpm{1} = defaults.segment.estimate.priors(1,:);
        jobs{1}.spatial{1}.preproc.opts.tpm{2} = defaults.segment.estimate.priors(2,:);
        jobs{1}.spatial{1}.preproc.opts.tpm{3} = defaults.segment.estimate.priors(3,:);
        jobs{1}.spatial{1}.preproc.data = {[datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.img']};
        spm_jobman('run',jobs)
    end


    if doWrite
        actWait = actWait+(1/maxWait);
        waitbar(actWait,wb,'Please wait...write AnalyseFiles!');
       
        % ---------- Normalise --------------------
        load se_normalise.mat; cnt = 1;
        jobs{1}.util{1}.defs.comp{1}.comp{1}.sn2def.matname = {[datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI_seg_sn.mat']};
        jobs{1}.util{1}.defs.comp{1}.comp{2}.sn2def.matname = {'colin27T1_seg_seg_inv_sn.mat'};
        for ses =1:numel(runs)
            if exist([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}])==7
                try
                    [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}],'*.img');
                    Files = [repmat([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep],size(Files,1),1) Files];
                    for file = 1:size(Files,1)
                        jobs{1}.util{1}.defs.fnames{cnt,1} = [Files(file,:)];
                        cnt = cnt+1;
                    end
                end
            end
        end
        jobs{1}.util{1}.defs.fnames{cnt,1} = [datapath{sub} subjects{sub} filesep paths{1} filesep subjects{sub} '_meanEPI.img'];

        if numel(structurals)>0
            [source,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep structurals{1}],'*.img');
            jobs{1}.util{1}.defs.fnames{cnt+1,1} = [datapath{sub} subjects{sub} filesep structurals{1} filesep source];

            se_defs(jobs{1}.util{1}.defs)
        end

    end

    if doMove
        actWait = actWait+(1/maxWait);
        waitbar(actWait,wb,'Please wait...move Files!');
        
        % ---------- Move normalised files --------------------
        for ses =1:numel(runs)
            try
                [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses}],'w*.*');
                if exist([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses}])==0
                    mkdir([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses}]);
                end
                for f = 1:size(Files,1)
                    movefile([datapath{sub} subjects{sub} filesep paths{1} filesep runs{ses} filesep Files(f,:)],...
                        [datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses} filesep Files(f,:)]);
                end
            end
        end
        % ---------- Move meanEPI files --------------------------
        mkdir([datapath{sub} subjects{sub} filesep paths{2}]);
        movefile([datapath{sub} subjects{sub} filesep paths{1} filesep 'w' subjects{sub} '_meanEPI.img'],...
            [datapath{sub} subjects{sub} filesep paths{2} filesep 'w' subjects{sub} '_meanEPI.img'])
        movefile([datapath{sub} subjects{sub} filesep paths{1} filesep 'w' subjects{sub} '_meanEPI.hdr'],...
            [datapath{sub} subjects{sub} filesep paths{2} filesep 'w' subjects{sub} '_meanEPI.hdr'])
        % ---------- Move anatomical T1 files --------------------------
        mkdir([datapath{sub} subjects{sub} filesep paths{2} filesep structurals{sub}]);
        [Files, Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep structurals{1}], '*.*');
        [num,b]=size(Files);
        for i=1:num
            fn = Files(i,:);
            l = length(fn);
            if (fn(1)=='w')
                if (fn(l-3:l)=='.img')
                    movefile([datapath{sub} subjects{sub} filesep structurals{1} filesep fn],...
                        [datapath{sub} subjects{sub} filesep paths{2} filesep structurals{1} filesep 'w' subjects{sub} '.img'])
                else
                    movefile([datapath{sub} subjects{sub} filesep structurals{1} filesep fn],...
                        [datapath{sub} subjects{sub} filesep paths{2} filesep structurals{1} filesep 'w' subjects{sub} '.hdr'])
                end
            end
        end
    end

    if doSmooth

        % ---------- Smooth --------------------
        load se_smooth.mat; cnt = 1;

        if numel(FWHM) == 1
            jobs{1}.spatial{1}.smooth.fwhm = [FWHM FWHM FWHM];
        else
            jobs{1}.spatial{1}.smooth.fwhm = [FWHM(1:3)];
        end


        for ses =1:numel(runs)
            if exist([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses}])==7
                try
                    [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses}],'w*.img');
                    Files = [repmat([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses} filesep],size(Files,1),1) Files];
                    for file = 1:size(Files,1)
                        jobs{1}.spatial{1}.smooth.data{cnt,1} = [Files(file,:) ',1']; cnt = cnt+1;
                    end
                end
            end
        end
        spm_jobman('run',jobs)




        % ---------- Move smoothed files --------------------
        for ses =1:numel(runs)
            if exist([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses}])==7
                try
                    mkdir([datapath{sub} subjects{sub} filesep paths{3} filesep runs{ses}]);
                    [Files,Dirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses}],'sw*.*');
                    for f = 1:size(Files,1)
                        movefile([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses} filesep Files(f,:)],...
                            [datapath{sub} subjects{sub} filesep paths{3} filesep runs{ses} filesep Files(f,:)]);
                    end
                end
            end
        end

    end
    fprintf('Transformation to Colin Ready\n');
    
    
    % ------------------------------------------------------------------------
    % Umwandlung Analyse in VMR
    % ------------------------------------------------------------------------
    actWait = actWait+(1/maxWait);
    waitbar(actWait,wb,'Please wait...Transformation to BV-Format - VMR!');
    %---------Daten "einlesen"--------------------------------------
    [VmrFiles,VmrDirs] = spm_list_files([datapath{sub} subjects{sub} filesep ...
        paths{2} filesep structurals{1}],'w*.img*');
    VmrFiles = [repmat([datapath{sub} subjects{1} filesep paths{2} filesep ...
        structurals{sub} filesep],size(VmrFiles,1),1) VmrFiles];
    VmrF = cell(size(VmrFiles,1),1);
    for i=1:size(VmrFiles,1),
        VmrF{i} = VmrFiles(i,:);
    end

    %--------Filename f�r vmr erstellen-------------------------------
    fnVMR = [datapath{sub} subjects{sub} filesep paths{2} filesep subjects{sub} 'toColin' '.vmr'];

    exportAnalyzeToVmr(VmrF,fnVMR);
      

    % ------------------------------------------------------------------------
    % Umwandlung von Analyze zu VTC
    % ------------------------------------------------------------------------
    actWait = actWait+(1/maxWait);
    waitbar(actWait,wb,'Please wait...Transformation to BV-Format - VTC!');
    
    %--------Daten "einlesen"-------------------------------------------------
    for ses =1:numel(runs)
        if exist([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses}])==7
            try
                [VtcFiles,VtcDirs] = spm_list_files([datapath{sub} subjects{sub} filesep paths{2}...
                filesep runs{ses}],'w*.hdr');
                VtcFiles = [repmat([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses} ...
                    filesep],size(VtcFiles,1),1) VtcFiles];
                VtcF = cell(size(VtcFiles,1),1);
                for i=1:size(VtcFiles,1),
                    VtcF{i} = VtcFiles(i,:);
                end;
                [num,a]=size(VtcF);

                 %--------Filename f�r vmr erstellen-------------------------------
                fnVTC = [datapath{sub} subjects{sub} filesep paths{2} filesep ...
                    subjects{sub} 'toColin' 'Run' runs{ses} '.vtc'];

                exportAnalyzeToVtc(VtcF,fnVTC);
            end
        end
    end
        
    actWait = actWait+(1/maxWait);
    waitbar(actWait,wb,'Transform Analyze to BVformat Ready');
    
    fprintf('Transform Analyze to BVformat Ready\n');
    
    
% %---------------------------------------------------------------------
% % Remove Data
% %---------------------------------------------------------------------
%
% % remove subject\Orig
% rmdir([datapath{sub} subjects{sub} filesep paths{1}],'s');
%
% % remove subject\3D
% rmdir([datapath{sub} subjects{sub} filesep structurals{1}],'s');
%
% % remove subject\Normalised\1
% for ses =1:numel(runs)
% try
% rmdir([datapath{sub} subjects{sub} filesep paths{2} filesep runs{ses}],'s');
% end
% end
%
% % remove subject\Normalised\3D
% rmdir([datapath{sub} subjects{sub} filesep paths{2} filesep structurals{1}],'s');
end

close(wb);
success = 1;


% INPUT Directory Structure

% Path to se_batchPreprocessing
% |
% |- Data (written like this, otherwise change in line 6)
% |
% |-Subject1 (name as provided by the variable "subjects")
% | |
% | |- DICOM
% | |
% | |- DICOM files for EPIs of Run 1 (directory name as provided by the variable "runs")
% | |- DICOM files for EPIs of Run 2 (directoryname as provided by the variable "runs") ...
% | |- DICOM files for EPIs of Run X (directoryname as provided by the variable "runs")
% | |- DICOM files for additional whole brain EPIs (directoryname as provided by the variable "wholeEPI")
% | |- DICOM files for anatomical T1 images (directoryname as provided by the variable "structurals")
% |
% |-Subject2 (name as provided by the variable "subjects")
% | |
% | |- DICOM
% | |
% | |- DICOM files for EPIs of Run 1 (directory name as provided by the variable "runs")
% | .
% | .
% | .
% |-Subject3 (name as provided by the variable "subjects")
% .
% .
% .


% OUTPUT Directory Structure

% Path to se_batchPreprocessing
% |
% |- Data (written like this, otherwise change in line 6)
% |
% |-Subject1 (name as provided by the variable "subjects")
% | |
% | |- DICOM
% | |- 3D
% | |- orig [Directory contains native-space and normalised mean EPI as well as the normalisation parameter file]
% | | |- Run 1 (directory name as provided by the variable "runs")
% | | |- Run 2 (directoryname as provided by the variable "runs") ...
% | | |- Run X (directoryname as provided by the variable "runs")
% | |
% | |- Normalised
% | | |- Run 1 (directory name as provided by the variable "runs")
% | | |- Run 2 (directoryname as provided by the variable "runs") ...
% | | |- Run X (directoryname as provided by the variable "runs")
% | |
% | |- Smooth_8mm
% | |- Run 1 (directory name as provided by the variable "runs")
% | |- Run 2 (directoryname as provided by the variable "runs") ...
% | |- Run X (directoryname as provided by the variable "runs")
% |-Subject2
% | |- DICOM
% | |- 3D
% | |- orig
% | |- Normalised
% | |- Smooth_8mm
% |-Subject3

Top of Message | Previous Page | Permalink

JiscMail Tools


RSS Feeds and Sharing


Advanced Options


Archives

May 2024
April 2024
March 2024
February 2024
January 2024
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
2006
2005
2004
2003
2002
2001
2000
1999
1998


JiscMail is a Jisc service.

View our service policies at https://www.jiscmail.ac.uk/policyandsecurity/ and Jisc's privacy policy at https://www.jisc.ac.uk/website/privacy-notice

For help and support help@jisc.ac.uk

Secured by F-Secure Anti-Virus CataList Email List Search Powered by the LISTSERV Email List Manager