Skip to content
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

Optional protocol_number parameter in experiment description #942

Open
k1o0 opened this issue Mar 3, 2025 · 0 comments
Open

Optional protocol_number parameter in experiment description #942

k1o0 opened this issue Mar 3, 2025 · 0 comments
Assignees

Comments

@k1o0
Copy link
Contributor

k1o0 commented Mar 3, 2025

On rare occasions the spacer number doesn't match the task position in the experiment description file.
We can make extraction easier in the future by first checking for a protocol_number key in each task dict. Relevant code:

task_protocols = acquisition_description.get('tasks', [])
for i, (protocol, task_info) in enumerate(chain(*map(dict.items, task_protocols))):
collection = task_info.get('collection', f'raw_task_data_{i:02}')
task_kwargs = {'protocol': protocol, 'collection': collection}
# For now the order of protocols in the list will take precedence. If collections are numbered,
# check that the numbers match the order. This may change in the future.
if re.match(r'^raw_task_data_\d{2}$', collection):
task_kwargs['protocol_number'] = i
if int(collection.split('_')[-1]) != i:
_logger.warning('Number in collection name does not match task order')

This was partially implemented already in the Task base class:
protocols = sess_params.get('tasks', [])
if task_protocol is None: # Return set of all task numbers
numbers = (next(iter(x.values()), {}).get('protocol_number') for x in protocols)
numbers = list(map(int, filter(lambda x: x is not None, numbers)))
return (next(iter(numbers)) if len(numbers) == 1 else numbers) or None

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant