prepare for new version
This commit is contained in:
@@ -32,20 +32,27 @@ class ExportToCSVWidget(CSVUIMixin, FlaresBaseWidget):
|
||||
design_matrix_dict: dict[str, DataFrame],
|
||||
contrast_results_dict: dict[str, dict[str, Any]],
|
||||
group_dict: dict[str, str],
|
||||
config_dict: dict[str, dict[str, Any]]
|
||||
config_dict: dict[str, dict[str, Any]],
|
||||
fir_feature_dict: dict[str, dict[str, Any]],
|
||||
qc_dict: dict[str, dict[str, Any]],
|
||||
) -> None:
|
||||
|
||||
super().__init__("ExportToCSV")
|
||||
self.setWindowTitle(f"Export To CSV Viewer - {APP_NAME.upper()}")
|
||||
self.haemo_dict = haemo_dict
|
||||
self.cha_dict = cha_dict
|
||||
# self.df_ind = df_ind_dict
|
||||
# self.design_matrix = design_matrix_dict
|
||||
# self.contrast_results_dict = contrast_results_dict
|
||||
# self.group = group_dict
|
||||
self.df_ind_dict = df_ind_dict
|
||||
self.design_matrix = design_matrix_dict
|
||||
self.contrast_results_dict = contrast_results_dict
|
||||
self.group_dict = group_dict
|
||||
self.config_dict = config_dict
|
||||
self.fir_feature_dict = fir_feature_dict
|
||||
self.qc_dict = qc_dict
|
||||
|
||||
self.setup_csv_ui(["0 (Export Data to CSV)", "1 (CSV for SPARKS)", "2 (Export Configuration to CSV)", "3 (Paragraph of Configuration)"])
|
||||
self.setup_csv_ui(["0 (Export Data to CSV)", "1 (CSV for SPARKS)", "2 (Export Configuration to CSV)", "3 (Paragraph of Configuration)", "4 (Export FIR Waveform Features to CSV)",
|
||||
"5 (Export Quality Control Metrics to CSV)",
|
||||
"6 (Export Master Consolidated Matrix [All Participants into 1 CSV])"
|
||||
])
|
||||
|
||||
|
||||
def process_request(self):
|
||||
@@ -113,6 +120,68 @@ class ExportToCSVWidget(CSVUIMixin, FlaresBaseWidget):
|
||||
magic_string = self.gen_magic_str(first_params)
|
||||
self.placeholder_label.setText(magic_string)
|
||||
|
||||
# elif idx == 4:
|
||||
# # FIR Waveform Features Export
|
||||
# fir_data = self.fir_feature_dict.get(file_path)
|
||||
# if fir_data and isinstance(fir_data, dict):
|
||||
# names = fir_data.get("feature_names", [])
|
||||
# vals = fir_data.get("features", [])
|
||||
# chans = fir_data.get("feature_channels", [])
|
||||
|
||||
# fir_df = DataFrame({
|
||||
# "Feature_Name": names,
|
||||
# "Channel": chans if len(chans) == len(names) else ["N/A"] * len(names),
|
||||
# "Value": vals
|
||||
# })
|
||||
# save_path = os.path.join(output_dir, f"{base_filename}_fir_features.csv")
|
||||
# fir_df.to_csv(save_path, index=False)
|
||||
# success_count += 1
|
||||
|
||||
# elif idx == 5:
|
||||
# # Quality Control (QC) Metrics Export
|
||||
# qc_data = self.qc_dict.get(file_path)
|
||||
# if qc_data and isinstance(qc_data, dict):
|
||||
# qc_df = DataFrame(list(qc_data.items()), columns=["Metric", "Value"])
|
||||
# save_path = os.path.join(output_dir, f"{base_filename}_qc_metrics.csv")
|
||||
# qc_df.to_csv(save_path, index=False)
|
||||
# success_count += 1
|
||||
|
||||
# elif idx == 6:
|
||||
# # Master Consolidated Matrix (1 single CSV combining all selected participants)
|
||||
# save_path = os.path.join(output_dir, f"{APP_NAME}_master_consolidated.csv")
|
||||
# if not os.path.exists(save_path):
|
||||
# master_rows: list[dict[str, Any]] = []
|
||||
# for fp in selected_file_paths:
|
||||
# abs_path = os.path.abspath(fp)
|
||||
# grp = self.group_dict.get(fp, "Unknown")
|
||||
# row: dict[str, Any] = {"Participant": abs_path, "Group": grp}
|
||||
|
||||
# # QC Metrics
|
||||
# qc_info = self.qc_dict.get(fp, {})
|
||||
# if isinstance(qc_info, dict):
|
||||
# for mk, mv in qc_info.items():
|
||||
# row[f"QC_{mk}"] = mv
|
||||
|
||||
# # FIR Features
|
||||
# fir_info = self.fir_feature_dict.get(fp, {})
|
||||
# print("1")
|
||||
# if isinstance(fir_info, dict):
|
||||
# print("2")
|
||||
# f_names = fir_info.get("feature_names", [])
|
||||
# f_vals = fir_info.get("features", [])
|
||||
# print("3")
|
||||
# if len(f_names) == len(f_vals):
|
||||
# print("4")
|
||||
# for fn, fv in zip(f_names, f_vals):
|
||||
# row[f"FIR_{fn}"] = fv
|
||||
|
||||
# master_rows.append(row)
|
||||
|
||||
# if master_rows:
|
||||
# df_master = DataFrame(master_rows)
|
||||
# df_master.to_csv(save_path, index=False)
|
||||
# success_count += 1
|
||||
|
||||
else:
|
||||
print(f"No method defined for index {idx}")
|
||||
|
||||
|
||||
@@ -64,7 +64,9 @@ DATA_SCHEMA = [
|
||||
{"key": "config_dict", "help": "Dict[file_path, dict]: Processing configuration parameters"},
|
||||
{"key": "fig_bytes_dict", "help": "Dict[file_path, dict]: Serialized figure data"},
|
||||
{"key": "contrast_results_dict", "help": "Dict[file_path, dict]: Calculated contrast statistical results"},
|
||||
{"key": "roi_channel_map_dict", "help": "Dict[file_path, dict]: Calculated contrast statistical results"},
|
||||
{"key": "roi_channel_map_dict", "help": "Dict[file_path, dict]: ROI channel mappings"},
|
||||
{"key": "fir_feature_dict", "help": "Dict[file_path, dict]: Extracted FIR waveform features (features, names, channels)"},
|
||||
{"key": "qc_dict", "help": "Dict[file_path, dict]: Quality control metrics"},
|
||||
{"key": "valid_dict", "help": "Dict[file_path, bool]: Boolean validity status per file"}
|
||||
]
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ class ViewerLauncherWidget(QWidget):
|
||||
fig_bytes_dict: dict[str, dict[str, bytes]],
|
||||
contrast_results_dict: dict[str, dict[str, Any]],
|
||||
roi_channel_map_dict: dict[str, dict[str, str]],
|
||||
fir_feature_dict: dict[str, dict[str, Any]],
|
||||
qc_dict: dict[str, dict[str, Any]],
|
||||
folding_bypass: bool,
|
||||
) -> None:
|
||||
|
||||
@@ -62,7 +64,7 @@ class ViewerLauncherWidget(QWidget):
|
||||
("Inter-Group Stats Viewer", InterGroupStatsWidget, [haemo_dict, cha_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, roi_channel_map_dict, group_dict], True),
|
||||
("Intra-Group Brain and Image Viewer", IntraGroupBrainImageWidget, [haemo_dict, cha_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, group_dict], True),
|
||||
("Inter-Group Brain and Image Viewer", InterGroupBrainImageWidget, [haemo_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, group_dict], True),
|
||||
("Export To CSV Viewer", ExportToCSVWidget, [haemo_dict, cha_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, group_dict, config_dict], True)
|
||||
("Export To CSV Viewer", ExportToCSVWidget, [haemo_dict, cha_dict, df_ind_dict, design_matrix_dict, contrast_results_dict, group_dict, config_dict, fir_feature_dict, qc_dict], True)
|
||||
]
|
||||
|
||||
layout = QVBoxLayout(self)
|
||||
|
||||
Reference in New Issue
Block a user