Home > bioelectromagnetism > eeg_save_graphics.m

eeg_save_graphics

PURPOSE ^

eeg_save_graphics - Save figure as graphics file

SYNOPSIS ^

function eeg_save_graphics(F,type,p,confirm)

DESCRIPTION ^

 eeg_save_graphics - Save figure as graphics file
 
 Usage: eeg_save_graphics(F,type,p,confirm)
 
 'F' is a figure handle, when empty uses 'gcf'
 
 'type' is the format of the graphic file, eg:
 
       'png'  - portable network graphics (default)
       'jpg'  - JPEG image, quality level of 90
       'tiff' - TIFF with packbits (lossless run-length encoding)
       'eps'  - encapsulated postscript
 
 Note that tiff and eps files can be very large.
 The default resolution is 300 DPI.
 
 'p' is the data struct of eeg_toolbox
 
 'confirm' is a boolean to control direct or GUI
 based saving.  0 = direct, 1 = GUI confirmation.
 
 The output file is saved to p.volt.path with
 the filename of the voltage file and the timing
 of the graphic appended (assumes that the graphic
 is a topographic map).

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function eeg_save_graphics(F,type,p,confirm)
0002 
0003 % eeg_save_graphics - Save figure as graphics file
0004 %
0005 % Usage: eeg_save_graphics(F,type,p,confirm)
0006 %
0007 % 'F' is a figure handle, when empty uses 'gcf'
0008 %
0009 % 'type' is the format of the graphic file, eg:
0010 %
0011 %       'png'  - portable network graphics (default)
0012 %       'jpg'  - JPEG image, quality level of 90
0013 %       'tiff' - TIFF with packbits (lossless run-length encoding)
0014 %       'eps'  - encapsulated postscript
0015 %
0016 % Note that tiff and eps files can be very large.
0017 % The default resolution is 300 DPI.
0018 %
0019 % 'p' is the data struct of eeg_toolbox
0020 %
0021 % 'confirm' is a boolean to control direct or GUI
0022 % based saving.  0 = direct, 1 = GUI confirmation.
0023 %
0024 % The output file is saved to p.volt.path with
0025 % the filename of the voltage file and the timing
0026 % of the graphic appended (assumes that the graphic
0027 % is a topographic map).
0028 %
0029 
0030 % $Revision: 1.1 $ $Date: 2004/11/12 01:32:33 $
0031 
0032 % Licence:  GNU GPL, no implied or express warranties
0033 % History:  04/2002, Darren.Weber_at_radiology.ucsf.edu
0034 %           - extracted out of eeg_contours_engine
0035 %
0036 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0037 
0038 if exist('F','var'),
0039     if isempty(F), F = gcf; end
0040 else
0041     F = gcf;
0042 end
0043 if exist('type','var'),
0044     if isempty(type), type = 'png'; end
0045 else
0046     type = 'png';
0047 end
0048 if exist('confirm','var'),
0049     if isempty(confirm), confirm = 0; end
0050 else
0051     confirm = 0;
0052 end
0053 
0054 
0055 [path,file,ext] = fileparts(strcat(p.volt.path,filesep,p.volt.file));
0056 if p.topoView,
0057     file = strcat(file, sprintf('_%s_%08.2f',p.topoView,p.volt.sampleTime),'.',type);
0058 else
0059     file = strcat(file, sprintf('_%08.2f',p.volt.sampleTime),'.',type);
0060 end
0061 file = fullfile(path,file);
0062 
0063 if confirm,
0064     [filename, filepath] = uiputfile(file, 'EEG Save Graphic');
0065     if ~isequal(filename,0),
0066         file = fullfile(filepath,filename);
0067         fprintf('EEG_SAVE_GRAPHIC: Saving to:...\n...%s\n',file);
0068         saveas(F,file);
0069     end
0070     
0071 else
0072     type = lower(type);
0073     if strmatch(type,'png'),
0074         driver = '-dpng';
0075         option1 = '-noui';
0076         option2 = '-r300';
0077         %option3 = '-zbuffer';
0078         fprintf('EEG_SAVE_GRAPHIC: Saving to:...\n...%s\n',file);
0079         print(F,driver,option1,option2,file);
0080     elseif strmatch(type,'jpeg'),
0081         driver  = '-djpeg90'; % JPEG image, quality level of nn (90 here)
0082         option1 = '-r300';
0083         fprintf('EEG_SAVE_GRAPHIC: Saving to:...\n...%s\n',file);
0084         print(F,driver,option1,file);
0085     elseif strmatch(type,'eps'),
0086         driver = '-depsc2'; % Encapsulated Level 2 Color PostScript
0087         option1 = '-r300';
0088         option2 = '-tiff';
0089         fprintf('EEG_SAVE_GRAPHIC: Saving to:...\n...%s\n',file);
0090         print(F,driver,option1,option2,file);
0091     elseif strmatch(type,'tiff'),
0092         driver = '-dtiff'; % TIFF with packbits (lossless run-length encoding) compression
0093         option1 = '-r300';
0094         fprintf('EEG_SAVE_GRAPHIC: Saving to:...\n...%s\n',file);
0095         print(F,driver,option1,file);
0096     else
0097         fprintf('EEG_SAVE_GRAPHIC: Saving to:...\n...%s\n',file);
0098         saveas(F,file);
0099     end
0100 end
0101 
0102 return

Generated on Mon 15-Aug-2005 15:36:19 by m2html © 2003