Skip to content

Commit

Permalink
Make logging optional in 'create_folders', improve docstring.
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeZiminski committed May 2, 2024
1 parent 577f959 commit 4497f42
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions datashuttle/datashuttle.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ def create_folders(
ses_names: Optional[Union[str, List[str]]] = None,
datatype: Union[str, List[str]] = "",
bypass_validation: bool = False,
log: bool = True,
) -> List[Path]:
"""
Create a subject / session folder tree in the project
Expand All @@ -160,31 +161,36 @@ def create_folders(
Parameters
----------
sub_names :
top_level_folder : TopLevelFolder
Whether to make the folders in `rawdata` or
`derivatives`.
sub_names : Union[str, List[str]]
subject name / list of subject names to make
within the top-level project folder
(if not already, these will be prefixed with
"sub-")
ses_names :
ses_names : Optional[Union[str, List[str]]]
(Optional). session name / list of session names.
(if not already, these will be prefixed with
"ses-"). If no session is provided, no session-level
folders are made.
datatype :
datatype : Union[str, List[str]]
The datatype to make in the sub / ses folders.
(e.g. "ephys", "behav", "anat"). If "all"
is selected, all datatypes permitted in
NeuroBlueprint will be created. If "" is passed
no datatype will be created.
top_level_folder :
Whether to make the folders in `rawdata` or
`derivatives`.
bypass_validation :
bypass_validation : bool
If `True`, folders will be created even if they are not
valid to NeuroBlueprint style.
log : bool
If `True`, details of folder creation will be logged.
Notes
-----
Expand Down Expand Up @@ -212,7 +218,8 @@ def create_folders(
["ses-001", "ses-002"],
["ephys", "behav"])
"""
self._start_log("create-folders", local_vars=locals())
if log:
self._start_log("create-folders", local_vars=locals())

utils.log("\nFormatting Names...")
ds_logger.log_names(["sub_names", "ses_names"], [sub_names, ses_names])
Expand Down Expand Up @@ -243,12 +250,14 @@ def create_folders(
log=True,
)

utils.print_message_to_user(
f"Finished making folders. \nFor log of all created "
f"folders, please see {self.cfg.logging_path}"
)
utils.print_message_to_user("Finished making folders.")

ds_logger.close_log_filehandler()
if log:
utils.print_message_to_user(
f"For log of all created folders, "
f"please see {self.cfg.logging_path}"
)
ds_logger.close_log_filehandler()

return created_paths

Expand Down

0 comments on commit 4497f42

Please sign in to comment.