thbndi commited on
Commit
5ef652e
1 Parent(s): 99440dc

Update day_intervals_cohort_v22.py

Browse files
Files changed (1) hide show
  1. day_intervals_cohort_v22.py +3 -14
day_intervals_cohort_v22.py CHANGED
@@ -187,18 +187,7 @@ def partition_by_mort(df:pd.DataFrame, group_col:str, visit_col:str, admit_col:s
187
 
188
  cohort = df.loc[(~df[admit_col].isna()) & (~df[disch_col].isna())]
189
 
190
- # cohort["label"] = (
191
- # (~cohort[death_col].isna())
192
- # & (cohort[death_col] >= cohort[admit_col])
193
- # & (cohort[death_col] <= cohort[disch_col])
194
- # )
195
- # cohort["label"] = cohort["label"].astype("Int32")
196
- #print("cohort",cohort.shape)
197
- #print(np.where(~cohort[death_col].isna(),1,0))
198
- #print(np.where(cohort.loc[death_col] >= cohort.loc[admit_col],1,0))
199
- #print(np.where(cohort.loc[death_col] <= cohort.loc[disch_col],1,0))
200
  cohort['label']=0
201
- #cohort=cohort.fillna(0)
202
  pos_cohort=cohort[~cohort[death_col].isna()]
203
  neg_cohort=cohort[cohort[death_col].isna()]
204
  neg_cohort=neg_cohort.fillna(0)
@@ -322,7 +311,7 @@ def extract_data(use_ICU:str, label:str, time:int, icd_code:str, root_dir,mimic_
322
  disease_label=disease_label,
323
  use_ICU=use_ICU
324
  )
325
- print("v22 fin get_visit_pts")
326
 
327
  # cols to be extracted from get_case_ctrls
328
  cols = [group_col, visit_col, admit_col, disch_col, 'Age','gender','ethnicity','insurance','label']
@@ -339,7 +328,7 @@ def extract_data(use_ICU:str, label:str, time:int, icd_code:str, root_dir,mimic_
339
 
340
  if use_ICU:
341
  cols.append(adm_visit_col)
342
- print('saving summary')
343
 
344
  if use_disease:
345
  hids=disease_cohort.extract_diag_cohort(cohort['hadm_id'],icd_code,mimic_path)
@@ -365,7 +354,7 @@ def extract_data(use_ICU:str, label:str, time:int, icd_code:str, root_dir,mimic_
365
  f.write(summary)
366
 
367
  print("[ SUMMARY SUCCESSFULLY SAVED ]")
368
- print(summary)
369
 
370
  return cohort_output
371
 
 
187
 
188
  cohort = df.loc[(~df[admit_col].isna()) & (~df[disch_col].isna())]
189
 
 
 
 
 
 
 
 
 
 
 
190
  cohort['label']=0
 
191
  pos_cohort=cohort[~cohort[death_col].isna()]
192
  neg_cohort=cohort[cohort[death_col].isna()]
193
  neg_cohort=neg_cohort.fillna(0)
 
311
  disease_label=disease_label,
312
  use_ICU=use_ICU
313
  )
314
+
315
 
316
  # cols to be extracted from get_case_ctrls
317
  cols = [group_col, visit_col, admit_col, disch_col, 'Age','gender','ethnicity','insurance','label']
 
328
 
329
  if use_ICU:
330
  cols.append(adm_visit_col)
331
+
332
 
333
  if use_disease:
334
  hids=disease_cohort.extract_diag_cohort(cohort['hadm_id'],icd_code,mimic_path)
 
354
  f.write(summary)
355
 
356
  print("[ SUMMARY SUCCESSFULLY SAVED ]")
357
+
358
 
359
  return cohort_output
360