@@ -108,50 +108,48 @@ def qc_cc_dfs(self, dfs, task):
108108 task = task )
109109 return categories , plots
110110
111- def qc_ps_dfs (self , dfs , task ):
112- categories , plots = [], []
113- plot_instance = PS_PLOTS ()
114- print (task )
115-
116- if task in ['PC' , 'LC' ]:
117- ps_instance = PS_QC ('response_time' , 'correct' , 1 , 0 , 'block_c' , 30000 )
118- for df in dfs [:]: # use a copy to safely modify the list during iteration
119- try :
120- subject = df ['subject_id' ][1 ]
121- except Exception as e :
122- print (f"Skipping df due to error accessing subject_id: { e } " )
123- dfs .remove (df )
124- continue
125-
126- print (f"qcing { subject } " )
127- category = ps_instance .ps_qc (df , threshold = 0.6 )
128- plot = plot_instance .lc_plot (df )
129- print (f"Category = { category } " )
130- categories .append ([subject , category , df ])
131- plots .append ([subject , plot ])
132-
133- else :
134- ps_instance = PS_QC ('block_dur' , 'correct' , 1 , 0 , 'block_c' , 125 )
135- for df in dfs [:]:
136- try :
137- subject = df ['subject_id' ][1 ]
138- except Exception as e :
139- print (f"Skipping df due to error accessing subject_id: { e } " )
140- dfs .remove (df )
141- continue
142-
143- print (f"qcing { subject } " )
144- category = ps_instance .ps_qc (df , threshold = 0.6 , DSST = True )
145- plot = plot_instance .dsst_plot (df )
146- print (f"Category = { category } " )
147- categories .append ([subject , category , df ])
148- plots .append ([subject , plot ])
149-
150- save_instance = SAVE_EVERYTHING ()
151- save_instance .save_dfs (categories = categories , task = task )
152- save_instance .save_plots (plots = plots , task = task )
153-
154- return categories , plots
111+ def qc_ps_dfs (self , dfs , task ):
112+ categories , plots = [], []
113+ plot_instance = PS_PLOTS ()
114+ print (task )
115+
116+ # Build a list of only valid DataFrames
117+ valid_dfs = []
118+ for df in dfs :
119+ try :
120+ # Use .iloc for a safe element access
121+ _ = df ['subject_id' ].iloc [1 ]
122+ valid_dfs .append (df )
123+ except Exception as e :
124+ print (f"Skipping df due to error accessing subject_id: { e } " )
125+
126+ # Process only the valid DataFrames
127+ if task in ['PC' , 'LC' ]:
128+ ps_instance = PS_QC ('response_time' , 'correct' , 1 , 0 , 'block_c' , 30000 )
129+ for df in valid_dfs :
130+ subject = df ['subject_id' ].iloc [1 ]
131+ print (f"qcing { subject } " )
132+ category = ps_instance .ps_qc (df , threshold = 0.6 )
133+ plot = plot_instance .lc_plot (df )
134+ print (f"Category = { category } " )
135+ categories .append ([subject , category , df ])
136+ plots .append ([subject , plot ])
137+ else :
138+ ps_instance = PS_QC ('block_dur' , 'correct' , 1 , 0 , 'block_c' , 125 )
139+ for df in valid_dfs :
140+ subject = df ['subject_id' ].iloc [1 ]
141+ print (f"qcing { subject } " )
142+ category = ps_instance .ps_qc (df , threshold = 0.6 , DSST = True )
143+ plot = plot_instance .dsst_plot (df )
144+ print (f"Category = { category } " )
145+ categories .append ([subject , category , df ])
146+ plots .append ([subject , plot ])
147+
148+ save_instance = SAVE_EVERYTHING ()
149+ save_instance .save_dfs (categories = categories , task = task )
150+ save_instance .save_plots (plots = plots , task = task )
151+
152+ return categories , plots
155153
156154
157155 def qc_mem_dfs (self , dfs , task ):
0 commit comments