In [1]:
%load_ext pymatbridge
In [2]:
import numpy as np
In [59]:
a = np.arange(64).reshape(4,4,4) + 1
mask = np.zeros((4,4,4))
mask[1:3,1:3,1:3] = 1
mask = mask == 1
In [60]:
mask
Out[60]:
In [61]:
a
Out[61]:
In [62]:
%%matlab
a = reshape(1:64, [4,4,4]);
mask = zeros(4,4,4);
mask(2:3,2:3,2:3) = 1;
a
mask = logical(mask)
In [63]:
vec = a[mask]
In [64]:
vec
Out[64]:
In [65]:
%%matlab
vec = a(mask)
Well, this is the same. So why the hell do I get different results when I do the same with nifti files?
In [66]:
import nibabel as nib
In [81]:
test_file = '/data1/scores/retest/out/sc07/stability_maps/_fmri_sub39529_session2_rest_stability_maps.nii.gz'
test_img = nib.load(test_file)
t_data = test_img.get_data()
t_net = t_data[...,0]
in_mask = '/data1/cambridge/template/template_cambridge_basc_multiscale_sym_scale007.nii.gz'
mask_img = nib.load(in_mask)
mask = mask_img.get_data() > 0
In [79]:
%%matlab
test_file = '/data1/scores/retest/out/sc07/stability_maps/_fmri_sub39529_session2_rest_stability_maps.nii.gz';
[t_hdr, t_data] = niak_read_vol(test_file);
t_net = t_data(:,:,:,1);
mask_template = '/data1/cambridge/template/template_cambridge_basc_multiscale_sym_scale007.nii.gz';
[m_hdr, m_vol] = niak_read_vol(mask_template);
mask = logical(m_vol);
In [70]:
mask.shape
Out[70]:
In [71]:
%%matlab
size(mask)
In [73]:
mask[10,20:30,20]
Out[73]:
In [74]:
%%matlab
mask(11,21:30,21)
Still the same story. What is up with the test data?
In [82]:
t_net.shape
Out[82]:
In [83]:
%%matlab
size(t_net)
In [85]:
t_net[10,20:30,30]
Out[85]:
In [86]:
%%matlab
t_net(11,21:30,31)
Still the same story
In [92]:
net_mask = t_net[mask]
net_mask[:5]
Out[92]:
In [91]:
%%matlab
net_mask = t_net(mask);
net_mask(1:5)
And now it is different. Are they using the rows and columns differently?
In [ ]: