get_session_dir

behavenet.fitting.utils.get_session_dir(hparams, session_source='save')[source]

Get session-level directory for saving model outputs from hparams dict.

Relies on hparams keys ‘sessions_csv’, ‘multisession’, ‘lab’, ‘expt’, ‘animal’, ‘session’.

The sessions_csv key takes precedence. The value for this key is a non-empty string of the pattern /path/to/session_info.csv, where session_info.csv has 4 columns for lab, expt, animal and session.

If sessions_csv is an empty string or the key is not in hparams, the following occurs:

  • if 'lab' == 'all', an error is thrown since multiple-lab runs are not currently supported

  • if 'expt' == 'all', all sessions from all animals from all expts from the specified lab are used; the session_dir will then be save_dir/lab/multisession-xx

  • if 'animal' == 'all', all sessions from all animals in the specified expt are used; the session_dir will then be save_dir/lab/expt/multisession-xx

  • if 'session' == 'all', all sessions from the specified animal are used; the session_dir will then be save_dir/lab/expt/animal/multisession-xx

  • if none of ‘lab’, ‘expt’, ‘animal’ or ‘session’ is ‘all’, session_dir is save_dir/lab/expt/animal/session

The session_source argument defines where the code looks for sessions whenever one of ‘lab’, ‘expt’, ‘animal’, or ‘session’ is 'all'; if 'session_source' = 'data', the data directory is searched for sessions; if 'session_source' = 'save', the save directory is searched for sessions. This means that only sessions that have been previously used for fitting models will be included.

The multisession-xx directory will contain a file session_info.csv which will contain information about the sessions that comprise the multisession; this file is used to determine whether or not a new multisession directory needs to be created.

Parameters:
  • hparams (dict) – requires sessions_csv, multisession, lab, expt, animal and session

  • session_source (str, optional) – ‘save’ to use hparams[‘save_dir’], ‘data’ to use hparams[‘data_dir’] as base directory; note that using path_type='data' will not return multisession directories

Returns:

  • session_dir (str)

  • sessions_single (list)

Return type:

tuple