=================
* Requirement
=================
 MATLAB7.0.1 or later + Optimization tool box
 caution : This program doesn't work on MATLAB7.0.4 because of the bug of copy command.
           (This information is added 2009/11)

===========================
* First time setup
===========================
 - Edit conf/positioning.ini

SubjectDatabase : Subject data will be saved this directory.
                  FACE-MAT file is put in the directory.
TempDir         : Temporary directory.
OutputDir       : Positioning result will be put here.
FailReportDir   : no need to change.

=================
* How to launch
=================

$>cd $POSITIONING
$>positioning

=================
 Document
=================
$POSITIONING/doc

SubjectRegistration.doc : How to register subject MRI.
                          It needs Analyze(LAS) file.
                          Please refer to $POSITIONING/Tips.txt
EEG_positioning_manual_fastscan2_0.doc : How to do EEG sensors positioning.
MEG_positioning_manual_fastscan2_0.doc : How to do MEG sensors positioning.

=================
* Functions
=================

*** MEG positioning(fastscan)
  Get transform matrix from MEG sensor coordinate to MRI coordinate.
  Fastscan data works as a mediator between MRI and MEG.

  requirement files
    (a) Analyze file(LAS)
    (b) DIGITIZER files
      (1) Stylus file(Fiducials(LPA, RPA, NASION) + MEG marker points on Face)
      (2) Scanned face file
      (3) MEG marker position file

  Operation
    1.Subject Registration(Analyze file)
    2.Push MEG positioning(fastscan) button
    3.Input stylus file + Scanned face file
    4.Fit Scanned face to MRI surface.
      (Stylus points are moved to MRI surface.)
    5.Input MEG marker position file.
    6.Fit MEG markers to marker points on MRI.
    --> You can get transform matrix for MEG sensor coordinate to MRI coordinate.

*** MEG positioning(MRI)
  Get transform matrix from MEG sensor coordinate to MRI coordinate.
  Fit meg markers on sensor coordinate system to mri markers that you selected on MRI.

  requirement files
    (a) Analyze file(LAS)
    (b) MEG marker file(MEG markers on sensor coordinate system.)

   Operation
    1.Subject Registration(Analyze file). 
      register marker points on MRI.
    2.Push MEG positioning(MRI) button
    3.Input MEG marker file
    4.Fit MEG markers to markers on MRI.
    --> You can get transform matrix for MEG sensor coordinate to MRI coordinate.

*** EEG positioning(fastscan)
   Get transform matrix from EEG sensor coordinate(digitizer coordinate) to MRI coordinate.

   Method 1 * Fiducials fitting *
     Positioning using fiducial points(LPA, RPA, Nasion)

     requirement files
       (a) Analyze file(LAS)
       (b) Stylus file(Fiducials(LPA, RPA, NASION) + channel locations)
       (c) Label file (channel label file)

     Operation
      1.Subject Registration(Analyze file).
      2.Push EEG positioning(fastscan)
      3.Input stylus file and label file.
      4.Fit fiducial points in stylus file to fiducial points on MRI.
        --> You can get transform matrix for EEG sensor coordinate to MRI coordinate.

   Method 2 * FACE fitting *
     Do positioning using scanned face surface and MRI surface.
     (The accuracy is higher than fiducials fitting)

     requirement files
       (a) Analyze file(LAS)
       (b) DIGITIZER files
          1) Stylus file(fiducials + channel locations)
          2) Scanned face file
       (c) Label file (channel label file)

     Operation
      1.Subject Registration(Analyze file).
      2.Push EEG positioning(fastscan)
      3.Input stylus file and scanned face file and label file.
      4.Fit scanned face to mri surface.
      --> You can get transform matrix for EEG sensor coordinate to MRI coordinate.

=====================
Output files
=====================
* Analyze file(LAS)
* FACE-MAT file
* FIT-MAT file
* POS-MAT file(s)

POS-MAT file contains positioning result and is used by VBMEG 
when importing MEG(EEG) data.

=====================
* Batch processing
=====================
$POSITIONING/batch/ReadMe.txt

currently, if you want to do batch positioning,
it needs both scanned face file and stylus file.

=========================
* compile mex functions
=========================
$>mex_compile

=====================
Notice
=====================
In this program, the YOKOGAWA library functions for importing 
YOKOGAWA MEG data into MATLAB are also included in the following directory.
$POSITIONING/external/yokogawa_lib

These library functions are provided by YOKOGAWA Co. and they are an old
version, which we have extensively used and tested for data analysis. 
YOKOGAWA Co. has now developed a new version for this library and will
distribute it in the internet through their home page. In our future 
version, we will update our program so that new YOKOGAWA library 
functions can be used.

==============================
* compile by MATLAB compiler
==============================
2007b and earlier
$>mcc -m positioning.m -a positioning.ini -a sample_stylus_points.png -a coronal.png -a axial.png -a sagittal.png -a template_biosemi32.mat -a template_biosemi64.mat -a template_biosemi128.mat -a digitizer_option.fig -a positioning_meg_device.fig

2008a and later(MATLAB Compiler 4.8) -C is added which is a setting to create CTF file.
$>mcc -C -m positioning.m -a positioning.ini -a sample_stylus_points.png -a coronal.png -a axial.png -a sagittal.png -a template_biosemi32.mat -a template_biosemi64.mat -a template_biosemi128.mat -a digitizer_option.fig -a positioning_meg_device.fig


==============================
* History
==============================
2011/6/15  Ver 1.00 released
2011/7/20  Ver 1.01 Save original filename (vrml_file, stylus_file, marker_file) into FIT-MAT file.
2011/8/9   Ver 1.02 small bug fix.
2012/7/23  Ver 1.03 1.added explanation about fiducial point registration(.doc).
                    2.updated dcm2nii tool.
                    3.fixed compatibility issue about fileparts function.
                    4.output directory can be specified by GUI.
                    5.Changed INI file(positioning.ini) location to top directory.
2012/10/24 Ver 1.04 Added figure: distance error of fiducial points to EEG positioning result.
2013/5/9   Ver 1.1  bugfix: Drive letter selection function doesn't work on a file dialog on windows 64bit.
                    bugfix: Deformative sphere model is created if a specified MRI's voxel size is not [1 1 1] mm.
2013/8/22  Ver 1.11 Added functionality to use extra head points for fit.
                    New yokogawa library is used when reading yokogawa marker file.
2015/1/22  Ver 1.12 bugfix about output directory settings.
