-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
System directory to support experiments #100
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"default": { | ||
"fields": [ | ||
{ | ||
"age": { | ||
"required": "false" | ||
} | ||
} | ||
], | ||
"summary": "Default experiment to test various BciPy features without registering a full experiment." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"age": { | ||
"help_text": "Age (in years) of user.", | ||
"type": "int" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,37 +5,41 @@ | |
import json | ||
|
||
|
||
def init_save_data_structure(data_save_path, | ||
user_information, | ||
parameters_used, | ||
mode=None, | ||
experiment_type=None): | ||
DEFAULT_EXPERIMENT_ID = 'default' | ||
|
||
|
||
def init_save_data_structure(data_save_path: str, | ||
user_id: str, | ||
parameters_path: str, | ||
experiment_id: str = DEFAULT_EXPERIMENT_ID, | ||
mode: str = None, | ||
experiment_type: int = None): | ||
""" | ||
Initialize Save Data Strucutre. | ||
|
||
data_save_path[str]: string of path to save our data in | ||
user_information[str]: string of user name / related information | ||
parameters_used[str]: a path to parameters file for the experiment | ||
user_id[str]: string of user name / related information | ||
parameters_path[str]: a path to parameters file for the experiment | ||
experiment_id[str]: Name of the experiment. Default name is DEFAULT_EXPERIMENT_ID. | ||
mode[str]: BCI mode. Ex. RSVP, SHUFFLE, MATRIX | ||
experiment_type[int]: type of experiment. Ex. 1 = calibration | ||
|
||
""" | ||
|
||
# make an experiment folder : note datetime is in utc | ||
save_folder_name = data_save_path + user_information | ||
save_folder_name = f'{data_save_path}{experiment_id}/{user_id}' | ||
dt = strftime('%a_%d_%b_%Y_%Hhr%Mmin%Ssec_%z', localtime()) | ||
|
||
# If there is a mode or experiment type registered add it to the folder structure | ||
if mode and experiment_type: | ||
save_directory = save_folder_name + '/' + \ | ||
user_information + '_' + str(mode) + '_' + str(experiment_type) + '_' + strftime( | ||
'%a_%d_%b_%Y_%Hhr%Mmin%Ssec_%z', localtime()) | ||
save_directory = f'{save_folder_name}/{user_id}_{mode}_{experiment_type}_{dt}' | ||
else: | ||
save_directory = save_folder_name + '/' + \ | ||
user_information + '_' + strftime( | ||
'%a_%d_%b_%Y_%Hhr%Mmin%Ssec_%z', localtime()) | ||
helper_folder_name = save_directory + '/helpers/' | ||
save_directory = f'{save_folder_name}/{user_id}_{dt}' | ||
|
||
try: | ||
# make a directory to save data to | ||
os.makedirs(save_folder_name) | ||
os.makedirs(save_directory) | ||
os.makedirs(helper_folder_name) | ||
os.makedirs(os.path.join(save_directory, 'logs'), exist_ok=True) | ||
|
||
except OSError as error: | ||
|
@@ -45,28 +49,13 @@ def init_save_data_structure(data_save_path, | |
|
||
# since this is only called on init, we can make another folder run | ||
os.makedirs(save_directory) | ||
os.makedirs(helper_folder_name) | ||
os.makedirs(os.path.join(save_directory, 'logs'), exist_ok=True) | ||
|
||
try: | ||
# Go to folder helpers and list files within it | ||
src_files = os.listdir('bcipy/helpers/') | ||
|
||
# Loop through files in helpers and copy important ones over | ||
for file_name in src_files: | ||
|
||
# get the full name | ||
full_file_name = os.path.join('bcipy/helpers/', file_name) | ||
|
||
# Check that constructed file is a real file and ends in .py | ||
if (os.path.isfile(full_file_name)) and '.py' in file_name: | ||
# Copy over! | ||
copy2(full_file_name, helper_folder_name) | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When I was looking into BIDS I meant to ask if these helpers are still needed. I'm glad we're able to clean up the data. |
||
# Check that parameters file given is a real file | ||
if (os.path.isfile(parameters_used)): | ||
if (os.path.isfile(parameters_path)): | ||
# Copy over parameters file | ||
copy2(parameters_used, save_directory) | ||
copy2(parameters_path, save_directory) | ||
else: | ||
raise Exception('Parameter File Not Found!') | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bci_main is passing an extra parameter to init_save_data_structure which causes an error (
experiment
). Sorry I didn't catch this during the review.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or actually, it looks like maybe this needs to be
experiment_id
, rather thanexperiment
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah - it should be experiment_id. I'll re-open a PR