* 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
#+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,'sessionskeletons.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)
    session_dict = orgutils.orgToDict(filename=session_path+'session.org')
#+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'))
    lab_meta_dict = {}
    lab_meta_dict['CODE'] = source_code_node.getValue()
    if 'LAB' in overview.keys():
        lab_meta_dict['LAB'] = overview['LAB'].getValue()
    nwbfile.add_lab_meta_data(lab_meta_dict)
#+END_SRC python
* SURVEYS  
** SUBJECT CREATE
*** AGE
#+survey
#+answer_type : int
*** DATE OF BIRTH
#+survey
*** DESCRIPTION
#+survey    
*** GENOTYPE
#+survey    
*** SEX
#+survey    
*** SPECIES
#+survey    
*** STRAIN
#+survey    
*** SUBJECT_ID
#+survey    
*** WEIGHT
#+survey
