MAL.Normalize

Previous  Next

 

ref_arr_out = MAL.Normalize( [BYREF arr_out       AS ARRAY],

                              BYREF arr_in        AS ARRAY,

                             [BYVAl nCount        AS INTEGER=3],

                             [BYVAL bSkipInvalids AS INTEGER=TRUE],

                             [BYVAL nPoint        AS INTEGER=ML_ALL],

                             [BYVAL nFrameOffset  AS INTEGER=0] ) AS REFERENCE

 


 

Normalizes a data set by taking averaging nCount samples from beginning of set and then subtract this value from each sample.  This will create change of motion relative to start.  The number of sample to average is determined by the nCount parameter.  The bSkipInvalids will cause the function to skip any invalids in the beginning and start averaging at the first non invalid value.  This is useful when you have a subject coming into the field of view and don't have any data until the subjet is in the view.

 

Example:

 

OPTION EXPLICIT ON

OPTION BASE 1

 

' Include C3D Support

$INCLUDE "MyBASIC2_C3DFile"

$LIBRARY "MyBASIC2_C3DFileLib"

 

' Needed to extract and Display Version

$LIBRARY "MyBASIC2_ExtLib"

 

' Include the MaxMAL Library

$INCLUDE "MyBASIC2_MaxMAL"

$LIBRARY "MyBASIC2_MaxMALLib"

 

' Forward Declare PrintArray and DisplayVersion

DECLARE SUB PrintArray

DECLARE SUB DisplayVersion

 

' Declare variables and arrays

DIM nPoints AS INTEGER

DIM nFrames AS INTEGER

DIM hFile   AS INTEGER

 

' Test File

CONST cFileName = "e:\walk8Invalids3.c3d"

 

CLS

 

' Display the current Library Version

CALL DisplayVersion()

 

' Open the Test File

hFile = C3DFile.Open( cFileName );

 

IF NOT hFile > 0 THEN

  PRINT "Error Opening File ";cFileName,

  STOP

ENDIF

 

' Get the no of points and frames

nFrames = C3DFile.GetNoOfFrames( hFile )

nPoints = C3DFile.GetNoOfPoints( hFile )

 

' Dimension the arrays

DIM Position(nFrames,nPoints,3)     AS REAL

DIM Normalized(nFrames,nPoints,3)   AS REAL

DIM Interpolated(nFrames,nPoints,3) AS REAL

DIM Filtered(nFrames,nPoints,3)     AS REAL

 

' Get the Point Coordinates from C3D file

IF C3DFile.GetPoints( hFile, Position ) <> nFrames THEN

  C3DFile.Close( hFile )

  PRINT "Error Reading ";nPoints;" from file ";cFileName,

  STOP

ENDIF

 

' Set the Frame Rate to use in the MaxMAL Library

MAL.FrameRate( C3DFile.GetFrameRate( hFile ) )

 

' Display the Position Coordinates

CALL PrintArray( REF( Position ) )

 

' Interpolate the data

MAL.Interpolate( Interpolated, Position, ML_SPLINE, 60, 2 )

CALL PrintArray( REF( Interpolated ) )

 

' Smooth the data with moving average (Default)

MAL.Filter( Filtered, Interpolated )

CALL PrintArray( REF( Filtered ) )

 

' Normalize the Data

MAL.Normalize( Normalized, Filtered )

CALL PrintArray( REF( Normalized ) )

 

' Just Normalize Point #1

CALL PrintArray( MAL.Normalize( Filtered, 3, TRUE, 1  ) )

 

' Close File

C3DFile.Close( hFile )

 

END

 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Print an array with up to 3 dimensions.  Array is passed as a reference

'

SUB PrintArray( arr AS REFERENCE )

  RUN( "ArrayPlot",  arr, TRUE )

END SUB

 

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' Display the MaxMAL Extension Library Version

'

SUB DisplayVersion()

  DIM major AS INTEGER

  DIM minor AS INTEGER

  DIM build AS INTEGER

  DIM qfe   AS INTEGER

 

  major = BYTE.HI( WORD.HI( MAL.Version() ) )

  minor = BYTE.LO( WORD.HI( MAL.Version() ) )

  build = BYTE.HI( WORD.LO( MAL.Version() ) )

  qfe   = BYTE.LO( WORD.LO( MAL.Version() ) )

 

  PRINT "Library Version: ";FORMAT( "%d, %d, %d, %d", major, minor, build, qfe ),

  PRINT "Option Flags:    ";FORMAT( "0x%08X", MAL.Version( TRUE ) ),

END SUB