attachment:cbu_write_fdt.m of DiffusionFdtNotes - MRC CBU Imaging Wiki
location: attachment:cbu_write_fdt.m of DiffusionFdtNotes

Attachment 'cbu_write_fdt.m'

Download

   1 function cbu_write_fdt(bvals, bvecs, outpath)
   2 % Write FSL FDT bvals and bvecs files from parameters
   3 % FORMAT write_fdt_files(bvals, bvecs, outpath)
   4 % 
   5 % bvals   - Nx1 vector with diffusion gradient strength
   6 %           (one per diffusion acquisition, N=no of acquisitions)
   7 % bvecs   - Nx3 matrix with diffusioon gradient directions
   8 %           
   9 % outpath - path to write FDT bvals, bvecs text files
  10 %           (defaults to current working directory)
  11 % 
  12 % If no input args, fetch bvals, bvecs using cbu_diffusion_params
  13 % 
  14 % Matthew Brett 30 April 2007
  15   
  16 if nargin < 2
  17   [bvals, bvecs] = cbu_diffusion_params();
  18 end
  19 if nargin < 3
  20   outpath = pwd;
  21 end
  22 
  23 fid = fopen('bvals', 'wt');
  24 if fid == -1
  25   error('Could not open bvals output file')
  26 end
  27 fprintf(fid, '   %e', bvals);
  28 fprintf(fid, '\n');
  29 fclose(fid);
  30 
  31 fid = fopen('bvecs', 'wt');
  32 if fid == -1
  33   error('Could not open bvecs output file')
  34 end
  35 % Implement nasty hack for inverted Y gradient directions
  36 disp('Inverting Y gradient directions, I hope that is OK')
  37 bvecs(:,2) = bvecs(:, 2)*-1
  38 for D = 1:3
  39   fprintf(fid, '   %e', bvecs(:,D));
  40   fprintf(fid, '\n');
  41 end
  42 fclose(fid);

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2007-04-30 15:55:44, 0.5 KB) [[attachment:cbu_diffusion_params.m]]
  • [get | view] (2007-04-30 15:55:59, 1.1 KB) [[attachment:cbu_write_fdt.m]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.