Changeset 129


Ignore:
Timestamp:
Jun 10, 2010, 9:13:47 AM (7 years ago)
Author:
tjniskan
Message:
  • Added plugin for correlation mapping with filtering/other options
  • Added flipping of 3D ROIs in aedes.m
  • Added possibility of changing ROI color (in the ROI -uimenu)
  • Minor fixes/changes here and there...

M misclib/fmri_spm_volumes.m
M misclib/fmri_filter.m
M aedes_fitmaps.m
M aedes.m
M plugins/save_roi_as_mask.m
M plugins/calc_asl_cbf.m
A plugins/fmri_plugins/correlation_mapping.m
M plugins/fmri_plugins/resting_state_fc.m
M plugins/map_plugins/t1_inversion_recovery.m
M aedes_revision.m

Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • aedes.m

    r126 r129  
    635635                       'checked','off',...
    636636                       'enable','off');
     637H.UIROISETCOLOR = uimenu(roi_tools_h,'Label','Set current ROI color',...
     638                       'callback',@l_RoiSetColor,...
     639                       'separator','off',...
     640                       'checked','off',...
     641                       'enable','off');                     
    637642
    638643H.UIROITOOLS_UNDO = uimenu(roi_tools_h,'Label','Undo draw (0)',...
     
    19661971                    H.UIROISHOWEDGES,...
    19671972                    H.UIROIRENAME,...
     1973                    H.UIROISETCOLOR,...
    19681974                    H.UIPUSH_STATS_ROI];
    19691975
     
    89738979end
    89748980
    8975 if ~Dat.isDataMixed
    8976   h=warndlg(['Volume ROI(s) cannot be flipped. Sorry...'],...
    8977             'Cannot flip ROIs','modal');
    8978   return
    8979 end
    89808981
    89818982% Get current ROI
     
    89848985% Add current ROI to undo buffer
    89858986l_RoiUndoBuffer('add_indices',currentRoi,[]);
    8986 
     8987 
    89878988% Loop over slices
    8988 for ii=1:length(ROI(currentRoi).voxels)
    8989   if strcmpi(opt,'flipud')
    8990         % FlipUD current ROI
    8991         ROI(currentRoi).voxels{ii} = flipud(ROI(currentRoi).voxels{ii});
    8992   elseif strcmpi(opt,'fliplr')
    8993         % FlipLR current ROI
    8994         ROI(currentRoi).voxels{ii} = fliplr(ROI(currentRoi).voxels{ii});
     8989if Dat.isDataMixed
     8990 
     8991  % Add current ROI to undo buffer
     8992  l_RoiUndoBuffer('add_indices',currentRoi,[]);
     8993 
     8994  for ii=1:length(ROI(currentRoi).voxels)
     8995    if strcmpi(opt,'flipud')
     8996      % FlipUD current ROI
     8997      ROI(currentRoi).voxels{ii} = flipud(ROI(currentRoi).voxels{ii});
     8998    elseif strcmpi(opt,'fliplr')
     8999      % FlipLR current ROI
     9000      ROI(currentRoi).voxels{ii} = fliplr(ROI(currentRoi).voxels{ii});
     9001    end
     9002  end
     9003else
     9004 
     9005  % Prompt for flip direction
     9006  if Dat.AxView==0
     9007    resp = questdlg('Select fliping plane', ...
     9008      'Flipping plane?', ...
     9009      'X', 'Y', 'Z', 'X');
     9010    if isempty(resp)
     9011      % Cancelled
     9012      return
     9013    end
     9014    FlipPlane = resp;
     9015  elseif Dat.AxView==1
     9016    if strcmpi(opt,'flipud')
     9017      FlipPlane='Y';
     9018    elseif strcmpi(opt,'fliplr')
     9019      FlipPlane='X';
     9020    end
     9021  elseif Dat.AxView==2
     9022    FlipPlane='Y';
     9023  else
     9024    FlipPlane='Z';
     9025  end
     9026 
     9027  if FlipPlane=='X'
     9028    if strcmpi(opt,'flipud')
     9029      ROI(currentRoi).voxels{1} = flipdim(ROI(currentRoi).voxels{1},1);
     9030    elseif strcmpi(opt,'fliplr')
     9031      ROI(currentRoi).voxels{1} = flipdim(ROI(currentRoi).voxels{1},2);
     9032    end
     9033  elseif FlipPlane=='Y'
     9034    if strcmpi(opt,'flipud')
     9035      ROI(currentRoi).voxels{1} = flipdim(ROI(currentRoi).voxels{1},1);
     9036    elseif strcmpi(opt,'fliplr')
     9037      ROI(currentRoi).voxels{1} = flipdim(ROI(currentRoi).voxels{1},3);
     9038    end
     9039  else
     9040    if strcmpi(opt,'flipud')
     9041      ROI(currentRoi).voxels{1} = flipdim(ROI(currentRoi).voxels{1},2);
     9042    elseif strcmpi(opt,'fliplr')
     9043      ROI(currentRoi).voxels{1} = flipdim(ROI(currentRoi).voxels{1},3);
     9044    end
    89959045  end
    89969046end
     
    93579407end
    93589408end % function l_ShowRoiEdges(h,
     9409
     9410%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     9411%%
     9412%% Set ROI color
     9413%%
     9414%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
     9415  function l_RoiSetColor(h,evd)
     9416    try
     9417      if isempty(ROI)
     9418        return
     9419      end
     9420     
     9421      roi_ind = get(H.ROI_EDIT,'value');
     9422      str = get(H.ROI_EDIT,'string');
     9423      str = str{roi_ind};
     9424      old_color = ROI(roi_ind).color./255;
     9425     
     9426      % Prompt for color
     9427      C=uisetcolor(old_color,['ROI: ',str]);
     9428     
     9429      % Set the new color
     9430      ROI(roi_ind).color = round(C*255);
     9431     
     9432      % Redraw ROIs
     9433      l_RefreshRoi;
     9434    catch
     9435      aedes_errordump(lasterror);
     9436    end
     9437  end
    93599438
    93609439%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  • aedes_fitmaps.m

    r80 r129  
    116116Dat.linear = true;
    117117Dat.wbar = true;
    118 Dat.MaxIter = 50; % Maximum number of iterations in nonlinear fits
     118Dat.MaxIter = 75; % Maximum number of iterations in nonlinear fits
    119119Dat.initVal = []; % Empty means that defaults are used for initial values
    120120ParentFileName = '';
  • aedes_revision.m

    r128 r129  
    9393% bash-script every time it is called so that this file "aedes_revision.m" is
    9494% always in the list of committed files. DO NOT EDIT THE NEXT LINE!!!
    95 % - Svn Hook -
     95% - SVN Hook -
  • misclib/fmri_filter.m

    r80 r129  
    4545filtered_data = double(data);
    4646
    47 if isempty(hipass) && isempty(lowpass) && ~detrend
     47if isempty(hipass) && isempty(lowpass) && ~detrending
    4848  return
    4949end
     
    126126end
    127127
    128 
    129 
    130 
    131 
  • misclib/fmri_spm_volumes.m

    r80 r129  
    11function fmri_spm_volumes(infile,outdir,varargin)
     2% This function reads VNMR EPI data and writes volumes in separate NIfTI
     3% files for SPM analysis
    24%
    3 %
    4 %
     5
    56
    67if nargin<2
    78  error('Too few input arguments')
     9end
     10
     11% Defaults
     12if infile(end)==filesep
     13  infile = infile(1:end-1);
     14end
     15[fp,fn,fe] = fileparts(infile);
     16if strcmpi(fn,'fid')
     17  [fp,fn,fe] = fileparts(fp);
     18  filename = fn;
     19  indir = fp;
     20else
     21  filename = fn;
     22  indir = infile;
     23end
     24
     25% If the outout directory does not contain a path
     26% try to create the output directory into the input
     27% directory...
     28if ~any(outdir==filesep)
     29  [tmp,msg,msg_id] = mkdir(indir,outdir);
     30  outdir = [indir,filesep,outdir];
    831end
    932
     
    1235end
    1336
    14 % Defaults
    15 [fp,fn,fe] = fileparts(infile);
    16 if strcmpi(fn,'fid')
    17   [fp,fn,fe] = fileparts(fp);
    18   filename = fn;
    19 else
    20   filename = fn;
    21 end
    2237VoxelSize = [1 1 1.5 2.039];
    2338XYZUnits = 'mm';
     
    6378
    6479% Read the fMRI data
    65 data = aedes_readfid(infile,'FastRead','on');
     80[data,msg] = aedes_readfid(infile,'precision','single');
    6681if isempty(data)
    67   disp('FMRI_SPM_VOLUMES: Action canceled...')
     82  fprintf(1,'FMRI_SPM_VOLUMES: Error reading data from %s...\n',infile)
    6883  return
    6984end
     
    8095  end
    8196else
    82   error('No PROCPAR found!')
     97  fprintf(1,'FMRI_SPM_VOLUMES: No PROCPAR found (%s)\n',infile)
     98  return
    8399end
    84100
    85 if isEPI
    86   % Remove first slice from EPI data
    87   data.FTDATA = data.FTDATA(:,:,:,2:end);
    88 end
    89101
    90102if isempty(StartVolume)
    91103  StartVolume = 1;
    92104end
    93 
    94105if isempty(EndVolume)
    95106  EndVolume = size(data.FTDATA,4);
    96107end
    97108
     109% Number of volumes to write
    98110nVols = length(StartVolume:EndVolume);
    99111
     112% Initialize waitbar
    100113wbh = aedes_wbar(0,['Writing volumes...']);
    101114
     
    116129 
    117130  % Rotate and flip volumes VNMR EPI and RASER to right orientations
    118   if isEPI
    119     vol = flipdim(aedes_rot3d(vol,1,3),2);
    120   elseif isRASER
    121     vol = flipdim(vol,2);
    122   end
     131  %if isEPI
     132  %  vol = flipdim(aedes_rot3d(vol,1,3),2);
     133  %elseif isRASER
     134  %  vol = flipdim(vol,2);
     135  %end
    123136 
    124137  % Construct file name
     
    126139 
    127140  % Write the NIfTI file
    128   done=aedes_write_nifti(vol,[outdir,fname],...
     141  tmp=aedes_write_nifti(vol,[outdir,fname],...
    129142    'VoxelSize',VoxelSize,...
    130143    'XYZUnits',XYZUnits,...
    131144    'TimeUnits',TimeUnits);
    132   if ~done
    133     error('Could not write file')
     145  if ~tmp
     146    fprintf(1,'Could not write file %s\n',[outdir,fname])
     147    return
    134148  end
    135149end
     
    141155
    142156
     157
    143158 
  • plugins/calc_asl_cbf.m

    r80 r129  
    5656        return
    5757  end
    58   controlIm = DATA{1}.FTDATA(:,:,1:2:size(DATA{1}.FTDATA,3));
    59   labelIm = DATA{1}.FTDATA(:,:,2:2:size(DATA{1}.FTDATA,3));
    60   ParentFileName = fullfile(DATA{1}.HDR.fpath,DATA{1}.HDR.fname);
     58  if isfield(DATA{1}.PROCPAR,'ltype') && ...
     59      length(DATA{1}.PROCPAR.ltype)==size(DATA{1}.FTDATA,3)
     60    control_ind = find(strcmpi(DATA{1}.PROCPAR.ltype,'c'));
     61    label_ind = find(strcmpi(DATA{1}.PROCPAR.ltype,'l'));
     62    controlIm = DATA{1}.FTDATA(:,:,control_ind);
     63    labelIm = DATA{1}.FTDATA(:,:,label_ind);
     64    ParentFileName = fullfile(DATA{1}.HDR.fpath,DATA{1}.HDR.fname);
     65  else
     66    controlIm = DATA{1}.FTDATA(:,:,1:2:size(DATA{1}.FTDATA,3));
     67    labelIm = DATA{1}.FTDATA(:,:,2:2:size(DATA{1}.FTDATA,3));
     68    ParentFileName = fullfile(DATA{1}.HDR.fpath,DATA{1}.HDR.fname);
     69  end
    6170end
    6271
     
    124133
    125134% Convert milliseconds to seconds
    126 t1map=t1map./1000;
     135%t1map=t1map./1000;
    127136
    128137% Calculate difference fotr ASL
    129138mean_control = mean(controlIm,3);
    130139mean_label = mean(labelIm,3);
    131 asl_map = mean_label-mean_control;
     140asl_map = mean_control-mean_label;
    132141
    133142% Calculate CBF and save it into a MAT-file
  • plugins/fmri_plugins/resting_state_fc.m

    r79 r129  
    1212end
    1313
    14 % Don't include the reference image from EPIs
    15 %if isfield(DATA{1},'PROCPAR') && isfield(DATA{1}.PROCPAR,'readres')
    16 %  data = DATA{1}.FTDATA(:,:,:,2:end);
    17 %else
    18   data=DATA{1}.FTDATA;
    19 %end
     14data=DATA{1}.FTDATA;
     15
    2016
    2117% Get the ROIs from current slice/volume
     
    2319  % Data volume upon which to show the maps
    2420  vol = data(:,:,1);
    25  
    2621  for ii=1:length(ROI)
    2722    ROI(ii).voxels{1} = ROI(ii).voxels{1}(:,:,AddInfo.CurrentSlice(3));
     
    3934% Spatially smooth data
    4035data = fmri_smooth(data,[2 2 1]);
    41 %aedes(data)
    4236
    43 % Filter data
    44 % data = fmri_filter(data,2.039,'hipass',0.009,...
    45 %   'lowpass',0.08);
     37% Do fMRI filtering
    4638data = fmri_filter(data,2,'detrending','on',...
    4739  'lowpass',0.08);
    48 %aedes(data)
    4940
    5041% Correlate seeds
     
    6253
    6354
     55
     56
     57
     58
     59
     60
  • plugins/map_plugins/t1_inversion_recovery.m

    r80 r129  
    2525end
    2626
     27if isfield(DATA{1},'PROCPAR') && isfield(DATA{1}.PROCPAR,'ti')
     28  fit_vals = DATA{1}.PROCPAR.ti;
     29end
     30
     31if isfield(DATA{1},'DataFormat') && strcmp(DATA{1}.DataFormat,'vnmr')
     32  [fp,fn,fe]=fileparts(fileparts(DATA{1}.HDR.fpath));
     33  default_filename = fn;
     34else
     35  default_filename = 't1_ir_map';
     36end
     37
    2738
    2839resp = aedes_inputdlg('Type TI values','Input dialog',...
     
    4051                    '*.*','All Files (*.*)'},...
    4152                               'Save T1-file',[DATA{1}.HDR.fpath, ...
    42                     't1_ir_map']);
     53                    default_filename]);
    4354if isequal(fname,0) || isequal(fpath,0)
    4455  return
  • plugins/save_roi_as_mask.m

    r80 r129  
    5656  return
    5757end
     58setpref('Aedes','PutDataFileDir',fpath);
    5859[fp,fn,fe]=fileparts([fpath,fname]);
    5960filename = [fp,filesep,fn,'.nii'];
Note: See TracChangeset for help on using the changeset viewer.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008