ImportML5ToILab

Declaration: ImportML5ToILab (IFile: TFileStream; var ErrorReport: string; Feedback: boolean): integer;
The function ImportML5ToILab loads the HSI data together with the meta data from a level 5 MatLab file which contains all the necessary information to reconstruct a complete and valid Epina ImageLab data structure. Please note the simplest way to generate a compatible MatLab 5 file is to use ExportILabToML5.

The parameter IFile points to a file stream containing the MatLab data, the variable parameter ErrrorReport returns a list of clear text error messages in the case of an error (i.e. if the function value is not zero).

The Feedback parameter determines whether the script progress bar indicates the progress of the calculations. Please note that unless the progress bar is already visible you have to make it visible before calling CorrectBaseLine, otherwise the feedback will not be displayed. You can activate the script progress bar by calling the function ScriptBar(0).

The function returns the following error codes:

 0 ... everything OK, the data is loaded
-1 ... not a valid level 5 MAT file
-2 ... the array "dataCube" (the raw data cube) is not specified
-3 ... one of the dimensions of the matrix is zero
-6 ... the author field is not specified
-7 ... the description field is not specified
-8 ... the sampleID field is not specified
-9 ... the tilePosition field is not specified
-10 ... the pixelMask field is not specified
-11 ... the number of pixel masks is limited to 32
-12 ... the pixelMaskName field is not specified
-13 ... the dimensions of pixelMaskName are incorrect
-14 ... the pixelAttribute field is not specified
-15 ... the pixelAttributeName field is not specified
-16 ... the dimensions of pixelAttributeName are incorrect
-17 ... the layerType field is not specified
-18 ... the dimensions of layerType are incorrect
-19 ... the derivativeOrder field is not specified
-20 ... the techData field is not specified
-21 ... the groupNumber field is not specified
-22 ... the axisCaptionX/Y/L/T field is not specified
-23 ... the dimensions of axisCaptionX/Y/L/T are incorrect
-24 ... the reverseFlagX/X/L/T field is not specified
-25 ... the sclOffsetX/Y/L/T field is not specified
-26 ... the sclCoeffsX/Y/L/T field is not specified
-27 ... the sclFactorX/Y/L/T field is not specified
-28 ... the sclXShiftX/Y/L/T field is not specified
-29 ... the sclOffsetInvX/Y/L/T field is not specified
-30 ... the sclCoeffsInvX/Y/L/T field is not specified
-31 ... the sclFactorInvX/Y/L/T field is not specified
-32 ... the sclXShiftInvX/Y/L/T field is not specified
-33 ... the numCalPiecesX/Y/L/T field is not specified
-34 ... the calPcsLimitsX/Y/L/T field is not specified
-35 ... the version field is not specified

Sample program: The following code lets you select a MatLab file. If the selected MatLab file is stored in MatLab 5 format, the data is loaded into Epina ImageLab:

program ImportFromML5;

var
  ErrorRep       : string;
  errnum         : integer;
  FName          : string;
  fs             : TFileStream;

begin
FName := SelectFile ('', '*.mat', 'Please select a MatLab 5 file');
if FName <> '' then
  begin
  fs := TFileStream.Create (FName, fmOpenRead);
  if not IsML5File (fs)
    then begin
         MessageDlg ('no ML5', mtError, [mbOK]);
         end
    else begin
         errnum := ImportML5toIlab (fs, ErrorRep);
         if errnum <> 0 then
           couts (errorRep);
         end;
  fs.Free;
  end;
end.