* SESSION IMPORTS
#+BEGIN_SRC python
import pynwb
import os
import argparse
from orgutils import orgutils
from pynwb import NWBHDF5IO
from pynwb import NWBFile
from datetime import datetime
from SAPOFTO import SAPOFTO
from SAPOFTO import recursiveFolderRead
#+END_SRC
* SESSION HEADER
#+BEGIN_SRC python
      #!!! This file was automatically generated by nwborg !!!
      # Code generated primarily from the parsing of: 
      #   - sessionskeletons.org
  def main():
      nwborg_root_path = '/'.join(os.path.dirname(os.path.realpath(__file__)).split('/')[:-2])+'/'
      overview = SAPOFTO.SAPOFTO(key='OVERVIEW',filename=os.path.join(nwborg_root_path,'overview.org'))
      skeleton = SAPOFTO.SAPOFTO(key='SKELETON',filename=os.path.join(nwborg_root_path,'session_skeletons.org'))['%-%-%SESSION_ARCHETYPE%-%-%']
      parser = argparse.ArgumentParser('Default parser generated automatically by nwborg')
      parser.add_argument('--session-id',type=str,default=-1,help='id for the session being run')
      args,unknown = parser.parse_known_args()
      session_id = args.session_id
      session_path = nwborg_root_path + 'sessions/%-%-%SESSION_ARCHETYPE%-%-%/' + session_id + '/'
      nwbfile = NWBFile(session_description=skeleton['description'].getValue(),identifier=session_id,session_start_time=datetime.now(),file_create_date=datetime.today())
      print('nwborg root path: ', nwborg_root_path)
      print('session path: ', session_path)
      lab_meta_dict = {}
      session_dict = orgutils.orgToDict(filename=session_path+'session.org')
      with open(__file__, 'r') as srcfile:
	  nwbfile.add_scratch(srcfile.read(), name='nwborglab_session_source_code', description='the source code used to generate this nwb file')
	  nwbfile.add_scratch(skeleton.castOrgLiteral(), name='nwborglab_session_skeleton', description='the raw org data describing in full the nwborglab session archetypes.')
	  nwbfile.add_scratch(overview.castOrgLiteral(), name='nwborglab_overview', description='metadata in raw org form pertaining to the of the nwborglab project responsible for this .nwb file')
	  nwbfile.add_scratch(recursiveFolderRead('sensors'), name='nwborglab_sensors', description='metadata in raw org form pertaining to the of the nwborglab project responsible for this .nwb file')
      with open('.nwborglab.org', 'r') as orgfile:
      nwbfile.add_scratch(srcfile.read(), name='nwborglab_sensors', description='metadata in raw org form pertaining to the of the nwborglab project responsible for this .nwb file')
#+END_SRC
* SESSION FOOTER
#+BEGIN_SRC python
    source_code_node = SAPOFTO.SAPOFTO(key='SOURCE_CODE',filename=os.path.join(nwborg_root_path,'sessions','%-%-%SESSION_ARCHETYPE%-%-%','run.py'))
#+END_SRC python
* OVERVIEW SRC
#+org_literal
** EXPERIMENT ABSTRACT
  this is where you can write about your experiment's abstract
** EXPERIMENT CONTRIBUTORS
   write down the names of your research contributors here
** LAB
   this is where you can specify which lab your experiment is affiliated with
** EXPERIMENT RESULTS
   This is where you can record the big picture results of your experiment
* SESSION_SKELETONS SRC
#+org_literal  
** EXAMPLE SESSION SKELE 1
   This is an example of a session skeleton. An actual session skeleton one should have a descriptive name in place of "* EXAMPLE SESSION SKELE 1"
   the experiment is a contrived example to give an idea of what kinds of information can be used in each of the fields
*** SUBJECT ROLES    
**** PIANO PLAYER
***** STIMULI
     - The subject will be prompted to improvise a minute long piano part using only a specific set of piano keys (length four)
     - Metronome at 80 bpm
***** SENSORS
      ultracortex
***** SURVEY
****** INITIAL      
******* Piano Developmental
#+survey	
     What age were you when you first started playing piano? If you've never played the piano just leave the answer blank.
******* Piano Broad Experience
#+survey	
    Briefly outline your experience playing the piano. Feel free to specify what kind of genres you feel most comfortable playing etc.
****** TERMINAL
******* Subjective Performance
#+survey
    On a scale from 1-10 how do you thnk you did?
	
***** OTHER NOTES
      The piano player will be seated facing away from the listener. 
**** LISTENER
***** STIMULI
      Listening to a 60 second improvised piece performed by the 'PIANO PLAYER' subject
***** SENSORS
      ultracortex
***** SURVEY
****** INITIAL      
******* Music preference
#+survey	
     What kind of music do you listen to? Feel free to specify artist/genre
******* Weekly Music Consumption
#+survey	
     How many hours a week do you listen to music?
****** TERMINAL
******* Subjective Performance
#+survey
    On a scale from 1-10 how do you think the piano player subject did?
	
******* Subjective Performance
#+survey
    if you had to guess, how long would you say the piano player subject has been playing piano
	
***** OTHER NOTES
** EXAMPLE SESSION SKELE 2
   This is an example of a session skeleton. An actual session skeleton one should have a descriptive name in place of "* EXAMPLE SESSION SKELE 2"
   the experiment is a contrived example to give an idea of what kinds of information can be used in each of the fields
*** SUBJECT ROLES    
**** SAXAPHONE PLAYER
***** STIMULI
     - The subject will be prompted to improvise a minute long saxaphone part using only a specific set of saxaphone keys (length four)
     - Metronome at 80 bpm
***** SENSORS
      ultracortex
***** SURVEY
****** INITIAL      
******* Saxaphone Developmental
#+survey	
     What age were you when you first started playing saxaphone? If you've never played the saxaphone just leave the answer blank.
******* Saxaphone Broad Experience
#+survey	
    Briefly outline your experience playing the saxaphone. Feel free to specify what kind of genres you feel most comfortable playing etc.
****** TERMINAL
******* Subjective Performance
#+survey
    On a scale from 1-10 how do you thnk you did?
	
***** OTHER NOTES
      The saxaphone player will be seated facing away from the listener. 
**** LISTENER
***** STIMULI
      Listening to a 60 second improvised piece performed by the 'SAXAPHONE PLAYER' subject
***** SENSORS
      ultracortex
***** SURVEY
****** INITIAL      
******* Music preference
#+survey	
     What kind of music do you listen to? Feel free to specify artist/genre
******* Weekly Music Consumption
#+survey	
     How many hours a week do you listen to music?
****** TERMINAL
******* Subjective Performance
#+survey
    On a scale from 1-10 how do you think the saxaphone player subject did?
	
******* Subjective Performance
#+survey
    if you had to guess, how long would you say the saxaphone player subject has been playing saxaphone
	
***** OTHER NOTES
    The listener will be wearing a sleep mask blindfold.
