# Last edited on 2020-03-09 00:25:31 by jstolfi

HUMAN MOTION DATASET

  This notebook describes the capture and processin of
  datasets on human motion.  
  
  The data is obtained by a system of infrared cameras that track a
  certain number {N} of retroreflective spherical markers (about 1 cm
  diameter) attached to specific points of the subject's body with
  two-sided adhesive tape.  The coordinates are obtained at a fast 
  sampling rate {fsmp}.  The software identifies the markers with 
  the help of a human operator.  The relevant data is therefore
  {fsmp} /frames/ per second, each frame being a list of {N} 
  Cartesian coordinate triples (in mm).
  
  The datasets in this directory were captured on 2020-03-03 by 
  Luiggi Lustosa and Ana Elisa Lemos Silva at UFRJ - Instituto 
  de Neurologia Deolindo Couto (INDC). The subject was Arthur Valencio.
  The equipmentd was Vicon Lock+, with 7 cameras (of the maximum 8).
  Marker identification was completed and corrected by Luiggi Lustosa.
  
ORIGINAL FILES

  The original files, as saved by Vicon software. were
  "csvraw/Arthur.Caminhada{01,...,13}.csv" in directory 
  
    projdir=projects/neuromat/00-DATA/2020-03-03-arthur-walks
  
  Each file contains two sections. The first section is data
  from a force measuring plate, that was not used in this 
  capture.  The second section starts with the word "Trajectories"
  alone in one line,vfollowed by one line with the sampling rate {fsmp} (in Hz),
  followed by three header, followed by the marker motion data proper.
  
  Each line in this section contains a data frame.  The first two fields
  are the "frame" and "subframe" indices.  Then come {3*N}  numbers,
  which are marker coordinates X, Y, and Z (in mm)
  The numbers are separated by commas, and the lines are terminated by 
  ASCII CR (octal \015, decimal 13) and ASCII LF (octal \012, decimall 10).

EXTRACTNG THE RELEVANT DATA
  
  Extracting the trajectory data as "Arthur.Caminhada[1-9].txt".
  This entails discarding the first section of each ".csv" file,
  removing the ASCII CR, replacing commas by blanks, removing spurious
  decimal fraction digits. and aligning the columns.
  
  Files 03 and 08 had problems. 
  
    # wknums=( 03 08 )
    # wknums=( 01 02 04 05 06 07 09 )
    wknums=( 10 11 12 13 )
    
    cd ~/${projdir}
    for kk in ${wknums[@]} ; do 
      nmwk_cleanup_vicon_csv.gawk \
          -v M=20 \
          csvraw/Arthur_caminhada${kk}.csv \
        > markers/avmk${kk}.txt
    done
    
  File 12 had one missing marker at the very end, starting on
  frame 3496.  Only 3495 frames copied.

GENERATING THE MARKER-BASED MOVIES
  
    projdir=projects/neuromat/00-DATA/2020-03-03-arthur-walks
    mkpovdir=posters/neuromat_homunculus

  The posters are created in directory  "${mkpovdir}".

  Linking to the data files:
  
    wknums=( 01 02 03 04 05 06 07 08 09 10 11 12 13 )
    cd ~/${mkpovdir}
    for kk in ${wknums[@]} ; do 
      ( cd in && ln -s ../../../${projdir}/markers/avmk${kk}.txt avmk${kk}.txt )
    done
    
  Making the maker-based movies:
  
    cd ~/${mkpovdir}
    # wknums=( 03 08 )
    wknums=( 01 02 04 05 06 07 09 10 11 12 13 )
    for kk in ${wknums[@]} ; do 
      make_marker_movie.sh avmk${kk} 0 15 10000 
    done

COMPUTING MATCHSTICK PART POSITIONS AND ORIENTATIONS

  Converting the marker positions to estimated positions
  and orentations of the parts of the matchkstick figure.
  
    projdir=projects/neuromat/00-DATA/2020-03-03-arthur-walks
 
    cd ~/${projdir}
    # wknums=( 03 08 )
    wknums=( 01 02 04 05 06 07 09 10 11 12 13 )
    for kk in ${wknums[@]} ; do 
      export PYTHONPATH=".:${HOME}/lib:"
      nmwk_vicon_to_matchstick.py \
        < markers/avmk${kk}.txt \
        > sticks/avst${kk}.txt
    done

GENERATING THE MATCHSTICK-BASED MOVIES

    projdir=projects/neuromat/00-DATA/2020-03-03-arthur-walks
    stpovdir=posters/neuromat_matchstick

  The posters are created in directory "${stpovdir}
  
  Linking to the data files:
  
    cd ~/${stpovdir}
    wknums=( 01 02 03 04 05 06 07 08 09 10 11 12 13 )
    for kk in ${wknums[@]} ; do 
      ( cd in \
          && ln -s ../../../${projdir}/sticks/avst${kk}.txt avst${kk}.txt \
          && ln -s ../../../${projdir}/markers/avmk${kk}.txt avmk${kk}.txt \
      )
    done
    
  Making the maker-based movies:
  
    cd ~/${stpovdir}
    # wknums=( 03 08 )
    wknums=( 01 02 04 05 06 07 09 10 11 12 13 )
    for kk in ${wknums[@]} ; do 
      make_matchstick_movie.sh av ${kk} 0 15 10000
    done
      
  The following script recomputes the matchstick parameters
  and remakes the movies with few frames, for quicker testing:
  
    test_matchstick.sh