Hi Eugenio,
what you want is easily achievable using spm and Matlab functionality.
The following should work, although the output is only to the Matlab
command window. Watch out for linebreaks when copying.
% ==== start ====
% get images to analyze
P = spm_select([Inf],'image','Select image(s)', [],pwd,'.*');
% loop over images
clc
for i = 1:size(P,1);
% get current image, filename
sub = deblank(P(i,:));
[p, nm, e, v] = spm_fileparts(sub);
disp(['... processing image ' nm ' from ' p '...']);
V = spm_vol(sub);
% load, clean data
vol = spm_read_vols(V);
vol(isnan(vol)) = 0;
vol(~isfinite(vol)) = 0;
% find, loop over clusters
[clus_vol,number] = spm_bwlabel(vol,18);
for ii = 1:number
% get coordinates, find center
temp = vol .* (clus_vol == ii);
coords = find(temp > 0);
[out{1:3}] = ind2sub(size(vol),coords);
ctr_v = mean(cell2mat(out),1);
% convert voxel to mm coordinates
ctr_mm = (V.mat(1:3,:) * [ ctr_v 1]')';
% round voxel coordinates
ctr_v = round(ctr_v);
% output to Matlab window
disp([' ... center ' num2str(ii) '/' num2str(number) ' is at voxel
' num2str(ctr_v(1,1)) '/' num2str(ctr_v(1,2)) '/' num2str(ctr_v(1,3)) ',
mm = ' sprintf('%02.2f', ctr_mm(1,1)) '/' sprintf('%02.2f', ctr_mm(1,2))
'/' sprintf('%02.2f', ctr_mm(1,3)) ]);
end;
end;
% ==== end ====
Hope this helps,
Marko
Eugenio Abela wrote:
> Dear Experts
>
> I have one binary image in native anatomical space that consists of ~80 clusters (locations of intracranial electrodes from an intensity segmented skull stripped CT image). I'd like to find the coordinates of this clusters but do not know how to code that in Matlab. Any hints are greatly appreciated.
>
> Regards
>
> Eugenio Abela, MD
>
> Research Fellow
> Dep. of Neurology
> University Hospital
> 3010 Bern/Switzerland
>
--
____________________________________________________
PD Dr. med. Marko Wilke
Facharzt für Kinder- und Jugendmedizin
Leiter, Experimentelle Pädiatrische Neurobildgebung
Universitäts-Kinderklinik
Abt. III (Neuropädiatrie)
Marko Wilke, MD, PhD
Pediatrician
Head, Experimental Pediatric Neuroimaging
University Children's Hospital
Dept. III (Pediatric Neurology)
Hoppe-Seyler-Str. 1
D - 72076 Tübingen, Germany
Tel. +49 7071 29-83416
Fax +49 7071 29-5473
[log in to unmask]
http://www.medizin.uni-tuebingen.de/kinder/epn/
____________________________________________________
|