1234567891011121314151617181920212223242526272829303132333435 |
- # -*- coding: utf-8 -*-
- """
- Created on Mon Apr 8 13:23:12 2024
- @author: arefks
- """
- import os
- import pandas as pd
- # Get the directory where the code file is located
- code_dir = os.path.dirname(os.path.abspath(__file__))
- # Get the parent directory of the code directory
- parent_dir = os.path.dirname(code_dir)
- # Read the behavior data CSV file into a Pandas DataFrame
- input_file_quant = os.path.join(parent_dir, 'output',"Final_Quantitative_output" ,'Quantitative_results_from_dwi_processing.csv')
- df_q = pd.read_csv(input_file_quant)
- # Read the behavior data CSV file into a Pandas DataFrame
- input_file_behav = os.path.join(parent_dir, 'output',"behavior_analysis" ,'behavior_data_processed.csv')
- df_b = pd.read_csv(input_file_behav)
- # Merge the columns from df_b into df_q based on subjectID and merged_timepoint columns
- merged_df = pd.merge(df_q, df_b[['subjectID', 'merged_timepoint', 'paw_drag', 'hindlimb_drop', 'foot_faults','paw_dragZ-score', 'hindlimb_dropZ-score', 'foot_faultsZ-score',
- 'averageScore', '2 Cluster', '3 Cluster', '4 Cluster', '5 Cluster', '6 Cluster']],
- on=['subjectID', 'merged_timepoint'], how='left')
- # Define the output file path
- output_file_path = os.path.join(parent_dir, 'output', 'Final_Quantitative_output','Quantitative_results_from_dwi_processing_merged_with_behavior_data.csv')
- # Save the merged DataFrame as a CSV file
- merged_df.to_csv(output_file_path, index=False)
|