Code covered by the BSD License  

Highlights from
sie2mat

image thumbnail

sie2mat

by

 

05 Aug 2013 (Updated )

The program sie2mat( SIE 2(to) MATlab ) reads binary SIE files and saves the data as a mat files

sie2mat( sie_flnme, varargin )
function [ ] = sie2mat( sie_flnme, varargin )
%sie2mat - calls sie2mat.exe and ssaves the data from the sie file as a mat
%file and loads the data to the Matlab workspace
%   Syntax
%       sie2mat( sie_flnme )  - returns a SIE_DATA structure with data from
%                               the sie file as defined in sie_flnme ans
%                               saves the stucture to the current working
%                               tirectory as SIE_DATA.mat
%       sie2mat( sie_flnme,'load_data', 'Yes/No' )  - defines if the sie
%                               data is loaded to the workspace
%                               Default - 'Yes'
%       sie2mat( sie_flnme,'delet_data', 'Yes/No' )  - defines if the mat
%                               data file should be deleted
%                               Default - 'No'
%       sie2mat( sie_flnme, 'sie2mat_loc', path_str )  -  path_str defines
%                               the location of the sie2mat.exe .
%                               Default - 'C:\Program Files\VDG\sie2mat\sie2mat.exe'
%       sie2mat( sie_flnme, 'data_name', struct_name_str )  -  data_name
%                               changes the name of the output structure to struct_name_str
%                               Default - 'SIE_DATA'
%       sie2mat( sie_flnme, 'save_data_name', save_data_name_str )  -  save_data_name
%                               defines the name of the output data mat file
%                               Default - 'SIE_DATA'
%       sie2mat( sie_flnme, 'video', video_int )  -  if video_out is
%                               set to 1, a vid_data structure will be
%                               created if a video data channel is found
%                               Default - 0
%       sie2mat( sie_flnme, 'video_name', video_name_str )  -  video_name
%                               changes the name of the output video structure to video_name_str
%       sie2mat( sie_flnme, 'save_video_name', save_video_name_str )  -  save_video_name
%                               defines the name of the output video mat file
%                               Default - 'SIE_VIDEO.mat'
%
% sie2mat.m
% Created by: MJ Stallmann
% Last modified: 11/03/2014

try
    %% Start sie2mat
    % get options
    [options] = parseOptions( varargin{:});
    % set path to MATLAB dll's
    system(['set PATH="' matlabroot '";%PATH% ']);
    % check if sie_flnme has a defined path, if not add current folder as path
    [pathstr, name, ext] = fileparts(sie_flnme) ;
    if isempty(pathstr)
        currentFolder = pwd;
        sie_flnme=fullfile(currentFolder,sie_flnme);
    end
    % run sie2mat.exe
    system(['"' options.sie2mat_loc '" -input "' sie_flnme '" -output_data  ' options.data_name ' -output_data_mat ' options.save_data_name ' -video ' num2str(options.video) ' -output_vid  ' options.video_name ' -output_vid_mat ' options.save_video_name ]);
    
    
    %% Load data file
    if strcmpi(options.load_data,'yes')
        flnme_data=options.save_data_name;
        data=load(flnme_data);
        assignin('base', options.data_name, data.(options.data_name))
        if options.video==1
            flnme_video=options.save_video_name;
            video_data=load(flnme_video);
            assignin('base', options.video_name, video_data.(options.video_name))
        end
    end
    
    %% Delete data file
    if strcmpi(options.delete_data,'yes')
        flnme_data=options.save_data_name;
        delete(flnme_data);
        if options.video==1
            flnme_video=options.save_video_name;
            delete(flnme_video);
        end
    end
catch err
    disp(' ... Error ...')
    rethrow(err);
end
end

%% Set options
function options = parseOptions(varargin)
IP = inputParser;
IP.addParamValue('sie2mat_loc', 'C:\Program Files\VDG\sie2mat\sie2mat.exe', @ischar)
IP.addParamValue('load_data','Yes', @ischar)
IP.addParamValue('delete_data','No', @ischar)
IP.addParamValue('data_name','SIE_DATA', @ischar)
IP.addParamValue('save_data_name','SIE_DATA.mat', @ischar)
IP.addParamValue('video',0, @isnumeric)
IP.addParamValue('video_name','SIE_VIDEO', @ischar)
IP.addParamValue('save_video_name','SIE_VIDEO.mat', @ischar)
IP.parse(varargin{:});
options = IP.Results;
end

Contact us