Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses BIDS compliance for outputs by updating how the tabular data and associated metadata are processed and saved. The proposed changes include transforming column names to snake case, renaming "subject_id" to "participant_id", reordering columns, and saving updated metadata and CSV/TSV data files.
| # Convert column names to snake case | ||
| out_df.columns = [col.lower().replace('-', '_').replace('.', '_') for col in out_df.columns] | ||
| # Rename subject_id to participant_id | ||
| out_df = out_df.rename(columns={'subject_id': 'participant_id'}) | ||
| # Reorder columns to have participant_id first | ||
| cols = out_df.columns.tolist() | ||
| cols.remove('participant_id') | ||
| out_df = out_df[['participant_id'] + cols] | ||
| # Replace missing values with "n/a" | ||
| out_df = out_df.fillna('n/a') |
There was a problem hiding this comment.
The transformation steps (converting column names, renaming, reordering, and filling missing values) are repeated for both out_df and data_df. Consider refactoring these into a common helper function to improve maintainability.
| # Convert column names to snake case | |
| out_df.columns = [col.lower().replace('-', '_').replace('.', '_') for col in out_df.columns] | |
| # Rename subject_id to participant_id | |
| out_df = out_df.rename(columns={'subject_id': 'participant_id'}) | |
| # Reorder columns to have participant_id first | |
| cols = out_df.columns.tolist() | |
| cols.remove('participant_id') | |
| out_df = out_df[['participant_id'] + cols] | |
| # Replace missing values with "n/a" | |
| out_df = out_df.fillna('n/a') | |
| # Apply transformations to the DataFrame | |
| out_df = transform_dataframe(out_df) |
There was a problem hiding this comment.
@tientong98 is this a good idea?
mattcieslak
left a comment
There was a problem hiding this comment.
Looks good! We can address the linting in another PR
Closes #1.