Skip to content

Fix output BIDS compliance#2

Merged
mattcieslak merged 3 commits intomainfrom
fix-bids-comp
Jun 11, 2025
Merged

Fix output BIDS compliance#2
mattcieslak merged 3 commits intomainfrom
fix-bids-comp

Conversation

@tien-tong
Copy link
Contributor

Closes #1.

@tien-tong tien-tong requested review from Copilot and mattcieslak June 11, 2025 16:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +142 to +151
# 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')
Copy link

Copilot AI Jun 11, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
# 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)

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

@tientong98 is this a good idea?

Copy link
Contributor

@mattcieslak mattcieslak left a comment

Choose a reason for hiding this comment

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

Looks good! We can address the linting in another PR

@mattcieslak mattcieslak merged commit c710470 into main Jun 11, 2025
1 check failed
@mattcieslak mattcieslak deleted the fix-bids-comp branch June 11, 2025 18:28
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.

Output needs to be BIDS compliant

3 participants