antspymm 1.3.3__py3-none-any.whl → 1.3.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- antspymm/mm.py +107 -44
- {antspymm-1.3.3.dist-info → antspymm-1.3.5.dist-info}/METADATA +1 -1
- antspymm-1.3.5.dist-info/RECORD +7 -0
- antspymm-1.3.3.dist-info/RECORD +0 -7
- {antspymm-1.3.3.dist-info → antspymm-1.3.5.dist-info}/LICENSE +0 -0
- {antspymm-1.3.3.dist-info → antspymm-1.3.5.dist-info}/WHEEL +0 -0
- {antspymm-1.3.3.dist-info → antspymm-1.3.5.dist-info}/top_level.txt +0 -0
antspymm/mm.py
CHANGED
@@ -1061,6 +1061,27 @@ def nrg_format_path( projectID, subjectID, date, modality, imageID, separator='-
|
|
1061
1061
|
return os.path.join( thedirectory, thefilename )
|
1062
1062
|
|
1063
1063
|
|
1064
|
+
def get_first_item_as_string(df, column_name):
|
1065
|
+
"""
|
1066
|
+
Check if the first item in the specified column of the DataFrame is a string.
|
1067
|
+
If it is not a string, attempt to convert it to an integer and then to a string.
|
1068
|
+
|
1069
|
+
Parameters:
|
1070
|
+
df (pd.DataFrame): The DataFrame to operate on.
|
1071
|
+
column_name (str): The name of the column to check.
|
1072
|
+
|
1073
|
+
Returns:
|
1074
|
+
str: The first item in the specified column, guaranteed to be returned as a string.
|
1075
|
+
"""
|
1076
|
+
if isinstance(df[column_name].iloc[0], str):
|
1077
|
+
return df[column_name].iloc[0]
|
1078
|
+
else:
|
1079
|
+
try:
|
1080
|
+
return str(int(df[column_name].iloc[0]))
|
1081
|
+
except ValueError:
|
1082
|
+
raise ValueError("The value cannot be converted to an integer.")
|
1083
|
+
|
1084
|
+
|
1064
1085
|
def study_dataframe_from_matched_dataframe( matched_dataframe, rootdir, outputdir, verbose=False ):
|
1065
1086
|
"""
|
1066
1087
|
converts the output of antspymm.match_modalities dataframe (one row) to that needed for a study-driving dataframe for input to mm_csv
|
@@ -1078,12 +1099,12 @@ def study_dataframe_from_matched_dataframe( matched_dataframe, rootdir, outputdi
|
|
1078
1099
|
musthavecols = ['projectID', 'subjectID','date','imageID','filename']
|
1079
1100
|
for k in range(len(musthavecols)):
|
1080
1101
|
if not musthavecols[k] in matched_dataframe.keys():
|
1081
|
-
raise ValueError('matched_dataframe is missing column ' +musthavecols[k] + ' in study_dataframe_from_qc_dataframe' )
|
1102
|
+
raise ValueError('matched_dataframe is missing column ' + musthavecols[k] + ' in study_dataframe_from_qc_dataframe' )
|
1082
1103
|
csvrow=matched_dataframe.dropna(axis=1)
|
1083
|
-
pid=
|
1084
|
-
sid=str(csvrow['subjectID'].iloc[0] )
|
1085
|
-
dt=str(csvrow['date'].iloc[0])
|
1086
|
-
iid=str(csvrow['imageID'].iloc[0])
|
1104
|
+
pid=get_first_item_as_string( csvrow, 'projectID' )
|
1105
|
+
sid=get_first_item_as_string( csvrow, 'subjectID' ) # str(csvrow['subjectID'].iloc[0] )
|
1106
|
+
dt=get_first_item_as_string( csvrow, 'date' ) # str(csvrow['date'].iloc[0])
|
1107
|
+
iid=get_first_item_as_string( csvrow, 'imageID' ) # str(csvrow['imageID'].iloc[0])
|
1087
1108
|
nrgt1fn=os.path.join( rootdir, pid, sid, dt, 'T1w', iid, str(csvrow['filename'].iloc[0]+iext) )
|
1088
1109
|
if not exists( nrgt1fn ):
|
1089
1110
|
raise ValueError("T1 " + nrgt1fn + " does not exist in study_dataframe_from_qc_dataframe")
|
@@ -1092,32 +1113,32 @@ def study_dataframe_from_matched_dataframe( matched_dataframe, rootdir, outputdi
|
|
1092
1113
|
rsfList=[]
|
1093
1114
|
nmList=[]
|
1094
1115
|
if 'flairfn' in csvrow.keys():
|
1095
|
-
flid=
|
1116
|
+
flid=get_first_item_as_string( csvrow, 'flairid' )
|
1096
1117
|
nrgt2fn=os.path.join( rootdir, pid, sid, dt, 'T2Flair', flid, str(csvrow['flairfn'].iloc[0]+iext) )
|
1097
1118
|
if exists( nrgt2fn ):
|
1098
1119
|
flList.append( nrgt2fn )
|
1099
1120
|
if 'dtfn1' in csvrow.keys():
|
1100
|
-
dtid=
|
1121
|
+
dtid=get_first_item_as_string( csvrow, 'dtid1' )
|
1101
1122
|
dtfn1=glob.glob(os.path.join( rootdir, pid, sid, dt, 'DTI*', dtid, str(csvrow['dtfn1'].iloc[0]+iext) ))[0]
|
1102
1123
|
if exists( dtfn1 ):
|
1103
1124
|
dtList.append( dtfn1 )
|
1104
1125
|
if 'dtfn2' in csvrow.keys():
|
1105
|
-
dtid=
|
1126
|
+
dtid=get_first_item_as_string( csvrow, 'dtid2' )
|
1106
1127
|
dtfn2=glob.glob(os.path.join(rootdir, pid, sid, dt, 'DTI*', dtid, str(csvrow['dtfn2'].iloc[0]+iext) ))[0]
|
1107
1128
|
if exists( dtfn2 ):
|
1108
1129
|
dtList.append( dtfn2 )
|
1109
1130
|
if 'dtfn3' in csvrow.keys():
|
1110
|
-
dtid=
|
1131
|
+
dtid=get_first_item_as_string( csvrow, 'dtid3' )
|
1111
1132
|
dtfn3=glob.glob(os.path.join(rootdir, pid, sid, dt, 'DTI*', dtid, str(csvrow['dtfn3'].iloc[0]+iext) ))[0]
|
1112
1133
|
if exists( dtfn3 ):
|
1113
1134
|
dtList.append( dtfn3 )
|
1114
1135
|
if 'rsffn1' in csvrow.keys():
|
1115
|
-
rsid=
|
1136
|
+
rsid=get_first_item_as_string( csvrow, 'rsfid1' )
|
1116
1137
|
rsfn1=glob.glob(os.path.join( rootdir, pid, sid, dt, 'rsfMRI*', rsid, str(csvrow['rsffn1'].iloc[0]+iext) ))[0]
|
1117
1138
|
if exists( rsfn1 ):
|
1118
1139
|
rsfList.append( rsfn1 )
|
1119
1140
|
if 'rsffn2' in csvrow.keys():
|
1120
|
-
rsid=
|
1141
|
+
rsid=get_first_item_as_string( csvrow, 'rsfid2' )
|
1121
1142
|
rsfn2=glob.glob(os.path.join( rootdir, pid, sid, dt, 'rsfMRI*', rsid, str(csvrow['rsffn2'].iloc[0]+iext) ))[0]
|
1122
1143
|
if exists( rsfn2 ):
|
1123
1144
|
rsfList.append( rsfn2 )
|
@@ -1125,7 +1146,7 @@ def study_dataframe_from_matched_dataframe( matched_dataframe, rootdir, outputdi
|
|
1125
1146
|
keyname="nmfn"+str(j)
|
1126
1147
|
keynameid="nmid"+str(j)
|
1127
1148
|
if keyname in csvrow.keys() and keynameid in csvrow.keys():
|
1128
|
-
nmid=
|
1149
|
+
nmid=get_first_item_as_string( csvrow, keynameid )
|
1129
1150
|
nmsearchpath=os.path.join( rootdir, pid, sid, dt, 'NM2DMT', nmid, "*"+nmid+iext)
|
1130
1151
|
nmfn=glob.glob( nmsearchpath )
|
1131
1152
|
nmfn=nmfn[0]
|
@@ -3430,6 +3451,9 @@ def dipy_dti_recon(
|
|
3430
3451
|
bvals = bvalsfn.copy()
|
3431
3452
|
bvecs = bvecsfn.copy()
|
3432
3453
|
|
3454
|
+
if bvals.max() < 1.0:
|
3455
|
+
raise ValueError("DTI recon error: maximum bvalues are too small.")
|
3456
|
+
|
3433
3457
|
b0_idx = segment_timeseries_by_bvalue( bvals )['highermeans']
|
3434
3458
|
|
3435
3459
|
b0 = ants.slice_image( image, axis=3, idx=b0_idx[0] )
|
@@ -7954,16 +7978,21 @@ def mm_csv(
|
|
7954
7978
|
hier['dataframes'], identifier=None )
|
7955
7979
|
t1wide.to_csv( hierfn + 'mmwide.csv' )
|
7956
7980
|
################# read the hierarchical data ###############################
|
7981
|
+
# over-write the rbp data with a consistent and recent approach ############
|
7982
|
+
myx = antspyt1w.inspect_raw_t1( t1, hierfn + 'rbp' , option='both' )
|
7983
|
+
del myx
|
7957
7984
|
hier = antspyt1w.read_hierarchical( hierfn )
|
7958
7985
|
if exists( hierfn + 'mmwide.csv' ) :
|
7959
7986
|
t1wide = pd.read_csv( hierfn + 'mmwide.csv' )
|
7960
7987
|
elif not testloop:
|
7961
7988
|
t1wide = antspyt1w.merge_hierarchical_csvs_to_wide_format(
|
7962
7989
|
hier['dataframes'], identifier=None )
|
7963
|
-
|
7964
|
-
|
7990
|
+
rgrade = str( t1wide['resnetGrade'].iloc[0] )
|
7991
|
+
if t1wide['resnetGrade'].iloc[0] < 0.20:
|
7965
7992
|
warnings.warn('T1w quality check indicates failure: ' + rgrade + " will not process." )
|
7966
7993
|
return
|
7994
|
+
else:
|
7995
|
+
print('T1w quality check indicates success: ' + rgrade + " will process." )
|
7967
7996
|
|
7968
7997
|
if srmodel_T1 is not False :
|
7969
7998
|
hierfntest = hierfnSR + 'mtl.csv'
|
@@ -9523,6 +9552,7 @@ def blind_image_assessment(
|
|
9523
9552
|
image_reference = ants.image_clone( image )
|
9524
9553
|
ntimepoints = 1
|
9525
9554
|
bvalueMax=None
|
9555
|
+
bvecnorm=None
|
9526
9556
|
if image_reference.dimension == 4:
|
9527
9557
|
ntimepoints = image_reference.shape[3]
|
9528
9558
|
if "DTI" in image_filename:
|
@@ -9535,6 +9565,8 @@ def blind_image_assessment(
|
|
9535
9565
|
if exists( bval_name ) and exists( bvec_name ):
|
9536
9566
|
bvals, bvecs = read_bvals_bvecs( bval_name , bvec_name )
|
9537
9567
|
bvalueMax = bvals.max()
|
9568
|
+
bvecnorm = np.linalg.norm(bvecs,axis=1).reshape( bvecs.shape[0],1 )
|
9569
|
+
bvecnorm = bvecnorm.max()
|
9538
9570
|
else:
|
9539
9571
|
image_b0 = ants.get_average_of_timeseries( image_reference ).iMath("Normalize")
|
9540
9572
|
else:
|
@@ -9700,11 +9732,11 @@ def blind_image_assessment(
|
|
9700
9732
|
noizlevel, snrref, cnrref, psnrref, ssimref, mymi, asym_err, myevr, msk_vol,
|
9701
9733
|
spc[0], spc[1], spc[2],org[0], org[1], org[2],
|
9702
9734
|
image.shape[0], image.shape[1], image.shape[2], ntimepoints,
|
9703
|
-
jjj, modality, mriseries, mrimfg, mrimodel, MagneticFieldStrength, mriSAR, PixelBandwidth, BandwidthPerPixelPhaseEncode, bvalueMax ]],
|
9735
|
+
jjj, modality, mriseries, mrimfg, mrimodel, MagneticFieldStrength, mriSAR, PixelBandwidth, BandwidthPerPixelPhaseEncode, bvalueMax, bvecnorm ]],
|
9704
9736
|
columns=[
|
9705
9737
|
'filename',
|
9706
9738
|
'dimensionality',
|
9707
|
-
'noise', 'snr', 'cnr', 'psnr', 'ssim', 'mi', 'reflection_err', 'EVR', 'msk_vol', 'spc0','spc1','spc2','org0','org1','org2','dimx','dimy','dimz','dimt','slice','modality', 'mriseries', 'mrimfg', 'mrimodel', 'mriMagneticFieldStrength', 'mriSAR', 'mriPixelBandwidth', 'mriPixelBandwidthPE', 'dti_bvalueMax' ])
|
9739
|
+
'noise', 'snr', 'cnr', 'psnr', 'ssim', 'mi', 'reflection_err', 'EVR', 'msk_vol', 'spc0','spc1','spc2','org0','org1','org2','dimx','dimy','dimz','dimt','slice','modality', 'mriseries', 'mrimfg', 'mrimodel', 'mriMagneticFieldStrength', 'mriSAR', 'mriPixelBandwidth', 'mriPixelBandwidthPE', 'dti_bvalueMax', 'dti_bvecnorm' ])
|
9708
9740
|
outdf = pd.concat( [outdf, df ], axis=0, ignore_index=False )
|
9709
9741
|
if verbose:
|
9710
9742
|
print( outdf )
|
@@ -10467,6 +10499,7 @@ def brainmap_figure(statistical_df, data_dictionary_path, output_prefix, brain_i
|
|
10467
10499
|
print(str(k) + " " + anattoshow[k] )
|
10468
10500
|
mysub = zz[zz['anat'].str.contains(anattoshow[k])]
|
10469
10501
|
anatsear=re.sub("dti.fa","",anattoshow[k])
|
10502
|
+
anatsear=re.sub("cbf.","",anatsear)
|
10470
10503
|
anatsear=re.sub("t1.volasym","",anatsear)
|
10471
10504
|
anatsear=re.sub("t1.thkasym","",anatsear)
|
10472
10505
|
anatsear=re.sub("t1.areaasym","",anatsear)
|
@@ -10482,6 +10515,8 @@ def brainmap_figure(statistical_df, data_dictionary_path, output_prefix, brain_i
|
|
10482
10515
|
anatsear=re.sub("dti.mean.fa.","",anatsear)
|
10483
10516
|
anatsear=re.sub("lravg","",anatsear)
|
10484
10517
|
atlassearch = mydict['tidynames'].str.contains(anatsear)
|
10518
|
+
if verbose:
|
10519
|
+
print( " anatsear " + anatsear + " atlassearch " )
|
10485
10520
|
if atlassearch.sum() > 0:
|
10486
10521
|
whichatlas = mydict[atlassearch]['Atlas'].iloc[0]
|
10487
10522
|
oglabelname = mydict[atlassearch]['Label'].iloc[0]
|
@@ -10490,13 +10525,13 @@ def brainmap_figure(statistical_df, data_dictionary_path, output_prefix, brain_i
|
|
10490
10525
|
oglabelname='unknown'
|
10491
10526
|
whichatlas=None
|
10492
10527
|
if verbose:
|
10493
|
-
print("oglabelname " + oglabelname )
|
10528
|
+
print("oglabelname " + oglabelname + " whichatlas " + str(whichatlas) )
|
10494
10529
|
vals2viz = mysub[col2viz].agg(['min', 'max'])
|
10495
10530
|
vals2viz = vals2viz[abs(vals2viz).idxmax()]
|
10496
10531
|
myext = None
|
10497
|
-
if 'dktcortex' in anattoshow[k]:
|
10532
|
+
if 'dktcortex' in anattoshow[k] or whichatlas == 'desikan-killiany-tourville' or 'dtkregions' in anattoshow[k]:
|
10498
10533
|
myext = 'dkt_cortex'
|
10499
|
-
elif 'cit168' in anattoshow[k]:
|
10534
|
+
elif 'cit168' in anattoshow[k] or whichatlas == 'CIT168':
|
10500
10535
|
myext = 'cit168lab'
|
10501
10536
|
elif 'mtl' in anattoshow[k]:
|
10502
10537
|
myext = 'mtl'
|
@@ -10601,9 +10636,17 @@ def brainmap_figure(statistical_df, data_dictionary_path, output_prefix, brain_i
|
|
10601
10636
|
print("oglabelname " + oglabelname )
|
10602
10637
|
|
10603
10638
|
if myext == 'cerebellum':
|
10604
|
-
atlasDescript
|
10605
|
-
|
10606
|
-
|
10639
|
+
if not atlasDescript.empty and 'Description' in atlasDescript.columns:
|
10640
|
+
atlasDescript['Description'] = atlasDescript['Description'].str.replace("l_", "")
|
10641
|
+
atlasDescript['Description'] = atlasDescript['Description'].str.replace("r_", "")
|
10642
|
+
oglabelname=re.sub("ravg","",oglabelname)
|
10643
|
+
oglabelname=re.sub("lavg","",oglabelname)
|
10644
|
+
whichindex = atlasDescript.index[atlasDescript['Description'] == oglabelname].values[0]
|
10645
|
+
else:
|
10646
|
+
if atlasDescript.empty:
|
10647
|
+
print("The DataFrame 'atlasDescript' is empty.")
|
10648
|
+
if 'Description' not in atlasDescript.columns:
|
10649
|
+
print("The column 'Description' does not exist in 'atlasDescript'.")
|
10607
10650
|
else:
|
10608
10651
|
whichindex = atlasDescript.index[atlasDescript['Description'].str.contains(oglabelname)]
|
10609
10652
|
|
@@ -10645,10 +10688,10 @@ def brainmap_figure(statistical_df, data_dictionary_path, output_prefix, brain_i
|
|
10645
10688
|
if fixed_overlay_range is not None:
|
10646
10689
|
addemC[0:3,0:3,0:3]=fixed_overlay_range[0]
|
10647
10690
|
addemC[4:7,4:7,4:7]=fixed_overlay_range[1]
|
10648
|
-
addemC[ addemC
|
10649
|
-
addemC[ addemC
|
10691
|
+
addemC[ addemC <= fixed_overlay_range[0] ] = 0 # fixed_overlay_range[0]
|
10692
|
+
addemC[ addemC >= fixed_overlay_range[1] ] = fixed_overlay_range[1]
|
10650
10693
|
ants.plot(edgeimgC, addemC, axis=axx, nslices=nslices, ncol=ncol,
|
10651
|
-
overlay_cmap=overlay_cmap, resample=False,
|
10694
|
+
overlay_cmap=overlay_cmap, resample=False, overlay_alpha=1.0,
|
10652
10695
|
filename=figfn, cbar=axx==axes[0], crop=True, black_bg=black_bg )
|
10653
10696
|
if verbose:
|
10654
10697
|
print(f"{col2viz} done")
|
@@ -10861,6 +10904,7 @@ def aggregate_antspymm_results_sdf(
|
|
10861
10904
|
splitsep='-',
|
10862
10905
|
idsep='-',
|
10863
10906
|
wild_card_modality_id=False,
|
10907
|
+
second_split=False,
|
10864
10908
|
verbose=False ):
|
10865
10909
|
"""
|
10866
10910
|
Aggregate ANTsPyMM results from the specified study data frame and store the aggregated results in a new data frame. This assumes data is organized on disk
|
@@ -10879,6 +10923,7 @@ def aggregate_antspymm_results_sdf(
|
|
10879
10923
|
- idsep (str): the separator used to partition subjectid date and imageid
|
10880
10924
|
for example, if idsep is - then we have subjectid-date-imageid
|
10881
10925
|
- wild_card_modality_id (bool): keep if False for safer execution
|
10926
|
+
- second_split (bool): this is a hack that will split the imageID by . and keep the first part of the split; may be needed when the input filenames contain .
|
10882
10927
|
- verbose : boolean
|
10883
10928
|
|
10884
10929
|
Note:
|
@@ -10950,22 +10995,34 @@ def aggregate_antspymm_results_sdf(
|
|
10950
10995
|
myfn = os.path.basename( df['filename'].iloc[x] )
|
10951
10996
|
temp = myfn.split( splitsep )
|
10952
10997
|
# Generalized search paths
|
10953
|
-
sid0 = str( temp[
|
10998
|
+
sid0 = str( temp[1] )
|
10954
10999
|
sid = str( df[subject_col].iloc[x] )
|
10955
11000
|
if sid0 != sid:
|
10956
|
-
warnings.warn("OUTER: the id derived from the filename " +
|
11001
|
+
warnings.warn("OUTER: the id derived from the filename " + sid0 + " does not match the id stored in the data frame " + sid )
|
10957
11002
|
warnings.warn( "filename is : " + myfn )
|
10958
11003
|
warnings.warn( "sid is : " + sid )
|
10959
11004
|
warnings.warn( "x is : " + str(x) )
|
10960
11005
|
myproj = str(df[project_col].iloc[x])
|
10961
11006
|
mydate = str(df[date_col].iloc[x])
|
10962
11007
|
myid = str(df[image_col].iloc[x])
|
11008
|
+
if second_split:
|
11009
|
+
myid = myid.split(".")[0]
|
10963
11010
|
path_template = base_path + "/" + myproj + "/" + sid + "/" + mydate + '/' + hiervariable + '/' + str(myid) + "/"
|
10964
11011
|
hierfn = sorted(glob( path_template + "*" + hiervariable + "*wide.csv" ) )
|
11012
|
+
if len( hierfn ) == 0:
|
11013
|
+
print( hierfn )
|
11014
|
+
print( path_template )
|
11015
|
+
print( myproj )
|
11016
|
+
print( sid )
|
11017
|
+
print( mydate )
|
11018
|
+
print( myid )
|
10965
11019
|
if len( hierfn ) > 0:
|
10966
11020
|
keep[x]=True
|
10967
11021
|
|
10968
|
-
df=df[keep]
|
11022
|
+
# df=df[keep]
|
11023
|
+
if df.shape[0] == 0:
|
11024
|
+
warnings.warn("input data frame shape is filtered down to zero")
|
11025
|
+
return df
|
10969
11026
|
|
10970
11027
|
if not df.index.is_unique:
|
10971
11028
|
warnings.warn("data frame does not have unique indices. we therefore reset the index to allow the function to continue on." )
|
@@ -10998,7 +11055,8 @@ def aggregate_antspymm_results_sdf(
|
|
10998
11055
|
myproj = str(df[project_col].iloc[x])
|
10999
11056
|
mydate = str(df[date_col].iloc[x])
|
11000
11057
|
myid = str(df[image_col].iloc[x])
|
11001
|
-
|
11058
|
+
if second_split:
|
11059
|
+
myid = myid.split(".")[0]
|
11002
11060
|
if verbose:
|
11003
11061
|
print( myfn )
|
11004
11062
|
print( temp )
|
@@ -11058,7 +11116,6 @@ def aggregate_antspymm_results_sdf(
|
|
11058
11116
|
nlarge = len(t1wfn)
|
11059
11117
|
t1wfn = find_most_recent_file( t1wfn )
|
11060
11118
|
warnings.warn("there are " + str( nlarge ) + " number of wide fns with search path " + modsearch + " we take the most recent of these " + t1wfn[0] )
|
11061
|
-
# raise ValueError("there are " + str( len( t1wfn ) ) + " number of wide fns with search path " + modsearch )
|
11062
11119
|
if len( t1wfn ) == 1:
|
11063
11120
|
if verbose:
|
11064
11121
|
print(t1wfn)
|
@@ -11076,9 +11133,11 @@ def aggregate_antspymm_results_sdf(
|
|
11076
11133
|
hdf.index = subdf.index.copy()
|
11077
11134
|
subdf = pd.concat( [subdf,hdf], axis=1, ignore_index=False)
|
11078
11135
|
dfout = pd.concat( [dfout,subdf], axis=0, ignore_index=False )
|
11079
|
-
|
11080
|
-
dfout
|
11081
|
-
|
11136
|
+
|
11137
|
+
if dfout.shape[0] > 0:
|
11138
|
+
badnames = get_names_from_data_frame( ['Unnamed'], dfout )
|
11139
|
+
dfout=dfout.drop(badnames, axis=1)
|
11140
|
+
return dfout
|
11082
11141
|
|
11083
11142
|
def enantiomorphic_filling_without_mask( image, axis=0, intensity='low' ):
|
11084
11143
|
"""
|
@@ -11197,8 +11256,11 @@ def mm_match_by_qc_scoring(df_a, df_b, match_column, criteria, prefix='matched_'
|
|
11197
11256
|
2. A DataFrame containing rows from df_b that were not matched to df_a.
|
11198
11257
|
"""
|
11199
11258
|
from scipy.stats import zscore
|
11200
|
-
df_a = df_a.loc[:, ~df_a.columns.str.startswith('Unnamed:')]
|
11201
|
-
df_b
|
11259
|
+
df_a = df_a.loc[:, ~df_a.columns.str.startswith('Unnamed:')].copy()
|
11260
|
+
if df_b is not None:
|
11261
|
+
df_b = df_b.loc[:, ~df_b.columns.str.startswith('Unnamed:')].copy()
|
11262
|
+
else:
|
11263
|
+
return df_a, pd.DataFrame()
|
11202
11264
|
|
11203
11265
|
# Normalize df_b based on criteria
|
11204
11266
|
for col, crit in criteria.items():
|
@@ -11378,15 +11440,16 @@ def mm_match_by_qc_scoring_all( qc_dataframe, fix_LRRL=True, verbose=True ):
|
|
11378
11440
|
|
11379
11441
|
prefixes = ['NM1_', 'NM2_', 'NM3_', 'NM4_', 'NM5_', 'NM6_']
|
11380
11442
|
undfmod = nmdf # Initialize 'undfmod' with 'nmdf' for the first iteration
|
11381
|
-
if
|
11382
|
-
|
11383
|
-
|
11384
|
-
|
11385
|
-
|
11386
|
-
|
11387
|
-
|
11388
|
-
|
11389
|
-
|
11443
|
+
if undfmod is not None:
|
11444
|
+
if verbose:
|
11445
|
+
print('start NM')
|
11446
|
+
print( undfmod.shape )
|
11447
|
+
for prefix in prefixes:
|
11448
|
+
if undfmod.shape[0] > 50:
|
11449
|
+
mmdf, undfmod = mm_match_by_qc_scoring(mmdf, undfmod, 'subjectIDdate', criteria, prefix=prefix, exclude_columns=xcl)
|
11450
|
+
if verbose:
|
11451
|
+
print( prefix )
|
11452
|
+
print( undfmod.shape )
|
11390
11453
|
|
11391
11454
|
criteria = {'ol_loop': 'min', 'noise': 'min', 'snr': 'max', 'EVR': 'max', 'dimt':'max'}
|
11392
11455
|
# higher bvalues lead to more noise ...
|
@@ -0,0 +1,7 @@
|
|
1
|
+
antspymm/__init__.py,sha256=1fHqufHndrkJwz473av8qOf5-1xm5r-aKHuMAETGIiE,4462
|
2
|
+
antspymm/mm.py,sha256=7UVUV4vASSwsASTT2aObJX4dg7mU28K4H85106BTuXM,479710
|
3
|
+
antspymm-1.3.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
4
|
+
antspymm-1.3.5.dist-info/METADATA,sha256=sJaL9YV5hUbe04k_j8YG0DhiNyyJc9CMBo-AdWDH6-M,14590
|
5
|
+
antspymm-1.3.5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
+
antspymm-1.3.5.dist-info/top_level.txt,sha256=iyD1sRhCKzfwKRJLq5ZUeV9xsv1cGQl8Ejp6QwXM1Zg,9
|
7
|
+
antspymm-1.3.5.dist-info/RECORD,,
|
antspymm-1.3.3.dist-info/RECORD
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
antspymm/__init__.py,sha256=1fHqufHndrkJwz473av8qOf5-1xm5r-aKHuMAETGIiE,4462
|
2
|
-
antspymm/mm.py,sha256=R7W1v2ejIjIc5FZaAVLfyX9De8R5A_W2U-AyHZenxUg,476733
|
3
|
-
antspymm-1.3.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
4
|
-
antspymm-1.3.3.dist-info/METADATA,sha256=PJy3nUwSUKIXi62KNJ73RlPBUwL16kX0ZP32gHq3IAg,14590
|
5
|
-
antspymm-1.3.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
6
|
-
antspymm-1.3.3.dist-info/top_level.txt,sha256=iyD1sRhCKzfwKRJLq5ZUeV9xsv1cGQl8Ejp6QwXM1Zg,9
|
7
|
-
antspymm-1.3.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|