Import the NIAK libraries. This notebook require:

  • jupyter with the octave kernel
  • an install of Octave with the image and statistics toolboxes from octave forge
  • data from the metaad project

In [1]:
cd /home/pbellec
build_path niak psom


Adding library niak to the search path.

Adding library psom to the search path.

Now build file names for p-value maps as well as "stats maps"


In [20]:
path_data = '/home/pbellec/data/metaad/clusterlevel_10k_less_conservative_mask/';
list_contrast = { '20160522_MCI_increase_clusterlevel_10k_less_conservative_mask' , ...
                  '20160523_MCI_decrease_clusterlevel_10k_less_conservative_mask' , ...
                  '20160601_AD_decrease_clusterlevel_10k_less_conservative_mask' , ...
                  '20160602_AD_increase_clusterlevel_10k_less_conservative_mask' };
list_p = cell(size(list_contrast));
list_s = cell(size(list_contrast));
for cc = 1:length(list_contrast)
  contrast = list_contrast{cc};
  file = [path_data contrast filesep '*_P.nii'];
  file = dir(file);
  list_p{cc} = file.name;
  if isempty(file)
      error('Could not find file %s',file)
  end
  file = [path_data contrast filesep '*_10k.nii'];
  file = dir(file);
  list_s{cc} = file.name;
  if isempty(file)
      error('Could not find file %s',file)
  end
end

Finally read the input volumes and convert them into a z image


In [25]:
for cc = 1:length(list_file)
  contrast = list_contrast{cc};
  file_s = [path_data contrast filesep list_s{cc}];
  [hdr,vol_s] = niak_read_vol(file_s);
  mask = vol_s>0;
  file = [path_data contrast filesep list_p{cc}];
  [hdr,vol] = niak_read_vol(file);
  figure
  subplot(1,2,1)
  opt_v.vol_limits = [0 3];
  niak_montage(-log10(vol),opt_v)
  min(vol(:))
  z = reshape(-niak_icdf_normal(vol(:),0,1),size(vol));
  z(mask==0) = 0;
  subplot(1,2,2)
  niak_montage(z,opt_v)
  [path_f,name_f,ext_f] = fileparts(file);
  name_f(end) = 'Z';
  hdr.file_name = [path_f filesep name_f ext_f];
  niak_write_vol(hdr,z);
end


ans =    5.0901e-07
warning: Matlab-style short-circuit operation performed for operator &
warning: called from
    niak_icdf_normal at line 82 column 1
ans =    1.1520e-06
warning: Matlab-style short-circuit operation performed for operator &
ans =    1.6950e-08
warning: Matlab-style short-circuit operation performed for operator &
ans =    3.1452e-07
warning: Matlab-style short-circuit operation performed for operator &

In [8]:
help niak_montage


'niak_montage' is a function from the file /home/pbellec/git/niak/commands/visualization/niak_montage.m

 Visualization of a 3D volume in a montage style (all slices in one image)

 SYNTAX: [] = NIAK_MONTAGE(VOL,OPT)

 _________________________________________________________________________
 INPUTS:

 VOL           
       (3D array) a 3D volume

 OPT           
       (structure, optional) has the following fields:

       NB_ROWS 
           (integer, default : optimized for a square montage) the number 
           of rows in the montage.
               
       NB_COLUMNS 
           (integer, default : optimized for a square montage) the number 
           of columns in the montage.

       VOXEL_SIZE 
           (vector 1*3, default [1 1 1]) resolution in x, y and z 
           dimensions (used if smoothing the volume).

       TYPE_SLICE 
           (string, default 'axial') the plane of slices in the montage. 
           Available options : 'axial', 'coronal', 'sagital', 'all'. 
           This option assumes the volume is in 'xyz' convention (left to 
           right, posterior to anterior, ventral to dorsal). With 'all' 
           option, three subplots will be made, one for each slice type.

       VOL_LIMITS 
           (vector 1*2, default [min(vol(:)) max(vol(:))]) limits of the 
           color scaling.

       TYPE_COLOR 
           (string, default 'jet') colormap name. Any regular type of 
			matlab colormap can be used. Additional options : 
				'jet_rev' a revert jet color map (red for low values, 
					blue for high values). Good for representing 
					distances.
				'hot_cold' designed for maps with both positive & 
					negative matrices.					

       FWHM 
           (double, default 0) smooth the image with a isotropic Gaussian 
           kernel of SMOOTH fwhm (in voxels).

       TYPE_FLIP 
           (string, default 'rot90') make rotation and flip of the slice 
           representation. see NIAK_FLIP_VOL for options. 
           'rot90' will work for axial slices of a volume oriented
           from left to right, from anterior to posterior, and 
           from ventral to dorsal. In this case, left is left on the 
           image.

       FLAG_COLORBAR 
           (boolean, default 1) if flag_colorbar is true, a colorbar is 
           included in the figure.

       COMMENT 
           (string, default '') a string that will appear in all figure 
           titles.

 _________________________________________________________________________
 OUTPUTS:

 a 'montage' style visualization of each slice of the volume

 _________________________________________________________________________
 COMMENTS:

 If both the number of rows ans the number of columns are specified, the
 number of slices are adapted to match the montage.

 Copyright (c) Pierre Bellec, 
 Montreal Neurological Institute, 2008-2010
 Departement d'informatique et de recherche operationnelle
 Centre de recherche de l'institut de Geriatrie de Montreal
 Universit de Montral, 2011-2015
 Maintainer : pierre.bellec@criugm.qc.ca


Additional help for built-in functions and operators is
available in the online version of the manual.  Use the command
'doc <topic>' to search the manual index.

Help and information about Octave is also available on the WWW
at http://www.octave.org and via the help@octave.org
mailing list.