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

Implement handling of bids_id column #34

Merged
merged 3 commits into from
Apr 20, 2023
Merged

Implement handling of bids_id column #34

merged 3 commits into from
Apr 20, 2023

Conversation

alyssadai
Copy link
Collaborator

@alyssadai alyssadai commented Apr 19, 2023

The most up-to-date bagel.csv files generated by mr_proc trackers will have an additional column bids_id (which will have values for subjects with BIDS imaging data) that is not currently defined in the bagel schema.

This PR adds it to the schema as an optional column and updates utility/plotting functions to handle this additional column when constructing the overview page of the dashboard.

Small changes:

  • example_bagel.csv updated: bids_id col added, nonsensical has_mri_data statuses fixed
  • Leftover TODO comment removed as it has been turned into a separate issue
  • Unhandled/unexpected exceptions which are caught during a callback are now printed in the terminal for debugging purposes

Closes #24

@alyssadai alyssadai marked this pull request as ready for review April 19, 2023 22:38
@surchs surchs self-requested a review April 20, 2023 17:48
Copy link
Contributor

@surchs surchs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧑‍🍳, left two 🍒 comments

@@ -183,7 +183,8 @@ def process_bagel(contents, filename):
data, total_subjects, sessions, upload_error = util.parse_csv_contents(
contents=contents, filename=filename
)
except Exception:
except Exception as exc:
print(exc) # for debugging
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can take a look at https://docs.python.org/3/library/logging.html to collect these types of messages and handle them - it gives you more clean control over what the output and where

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(for a later PR)

@@ -65,13 +64,21 @@ def extract_pipelines(bagel: pd.DataFrame) -> dict:
return pipelines_dict


def get_id_columns(data: pd.DataFrame) -> list:
"""Returns names of columns which identify a given participant record"""
return (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, but: is there a reason to do this over just if ... return; else return? I find that cleaner to read

Copy link
Collaborator Author

@alyssadai alyssadai Apr 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, mainly brevity. In some past PRs I've gotten suggestions to switch simple if-else (that is, returning a single object) blocks to ternary operators, so I guess the preference depends on who's reviewing the code 😅. I would like to keep the style consistent across the app, if possible. Would you recommend defaulting to if ... return; else return ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I think this is still readable as is. I would not use ternary if this got any longer. Consistency is a good idea, so if you've used this elsewhere, then let's keep it

@@ -65,13 +64,21 @@ def extract_pipelines(bagel: pd.DataFrame) -> dict:
return pipelines_dict


def get_id_columns(data: pd.DataFrame) -> list:
"""Returns names of columns which identify a given participant record"""
return (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, I think this is still readable as is. I would not use ternary if this got any longer. Consistency is a good idea, so if you've used this elsewhere, then let's keep it

@alyssadai alyssadai merged commit e0df7e6 into main Apr 20, 2023
@alyssadai alyssadai deleted the feat-24/add-bids-id branch April 20, 2023 20:40
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

Successfully merging this pull request may close these issues.

Add handling of bids_id column
2 participants