Bonjour,
je travaille sur les méthodes de recalage en imagerie.
j'utilise SPM sous matlab.
les méthodes sont déjà codé et j'aimerais comprendre étape par étape leur fonctionnement.
je travaille actuellement dessus, mais vu que j'aurais beaucoup de méthodes à voir, j'aimerais avoir votre aide pour aller plus vite.

la première méthode est "la normalisation" spm_coreg.

dans spm_coreg on utilise spm_vol, j'aimerais comprendre son fonctionnement.

Merci beaucoup pour votre aide

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
function V = spm_vol(P)
%définition d'une structure de volume
if nargin==0, % nombre d'arguments données 
    V   = struct('fname', {},...
                 'dim',   {},...
                 'dt',    {},...
                 'pinfo', {},...
                 'mat',   {},...
                 'n',     {},...
                 'descrip', {},...
                 'private',{});
    return;
end;
 
% If is already a vol structure then just return;
if isstruct(P), V = P; return; end; %on vérifie que P  est bien une structure de volume et V prends P
 
V = subfunc2(P);
return;
%_______________________________________________________________________
 
%_______________________________________________________________________
function V = subfunc2(P)
if iscell(P),
    V = cell(size(P));
    for j=1:numel(P),
        if iscell(P{j}),
            V{j} = subfunc2(P{j});
        else
            V{j} = subfunc1(P{j});
        end;
    end;
else
    V = subfunc1(P);
end;
return;
%_______________________________________________________________________
 
%_______________________________________________________________________
function V = subfunc1(P)
if isempty(P),
    V = [];
    return;
end;
 
counter = 0;
for i=1:size(P,1),
    v = subfunc(P(i,:));
    [V(counter+1:counter+size(v, 2),1).fname] = deal('');
    [V(counter+1:counter+size(v, 2),1).mat] = deal([0 0 0 0]);
    [V(counter+1:counter+size(v, 2),1).mat] = deal(eye(4));
    [V(counter+1:counter+size(v, 2),1).mat] = deal([1 0 0]');
    if isempty(v),
        hread_error_message(P(i,:));
        error(['Can''t get volume information for ''' P(i,:) '''']);
    end
 
    f = fieldnames(v);
    for j=1:size(f,1)
        eval(['[V(counter+1:counter+size(v,2),1).' f{j} '] = deal(v.' f{j} ');']);
    end
    counter = counter + size(v,2);
end
 
return;
%_______________________________________________________________________
 
%_______________________________________________________________________
function V = subfunc(p)
[pth,nam,ext,n1] = spm_fileparts(deblank(p));
p = fullfile(pth,[nam ext]);
n = str2num(n1);
if ~spm_existfile(p),
    %existance_error_message(p);
    error('File "%s" does not exist.', p);
end
switch ext,
    case {'.nii','.NII'},
        % Do nothing
 
    case {'.img','.IMG'},
        if ~spm_existfile(fullfile(pth,[nam '.hdr'])) && ~spm_existfile(fullfile(pth,[nam '.HDR'])),
            %existance_error_message(fullfile(pth,[nam '.hdr'])),
            error('File "%s" does not exist.', fullfile(pth,[nam '.hdr']));
        end
 
    case {'.hdr','.HDR'},
        ext = '.img';
        p   = fullfile(pth,[nam ext]);
        if ~spm_existfile(p),
            %existance_error_message(p),
            error('File "%s" does not exist.', p);
        end
 
    otherwise,
        error('File "%s" is not of a recognised type.', p);
end
 
if isempty(n),
    V = spm_vol_nifti(p);
else
    V = spm_vol_nifti(p,n);
end;
 
if isempty(n) && length(V.private.dat.dim) > 3
    V0(1) = V;
    for i = 2:V.private.dat.dim(4)
        V0(i) = spm_vol_nifti(p, i);
    end
    V = V0;
end
if ~isempty(V), return; end;
return;
%_______________________________________________________________________
 
%_______________________________________________________________________
function hread_error_message(q)
str = {...
    'Error reading information on:',...
    ['        ',spm_str_manip(q,'k40d')],...
    ' ',...
    'Please check that it is in the correct format.'};
spm('alert*',str,mfilename,sqrt(-1));
return;
%_______________________________________________________________________
 
%_______________________________________________________________________
function existance_error_message(q)
str = {...
        'Unable to find file:',...
        ['        ',spm_str_manip(q,'k40d')],...
        ' ',...
        'Please check that it exists.'};
spm('alert*',str,mfilename,sqrt(-1));
return;