Skip to content

Commit

Permalink
Merge pull request #319 from Nitesh639/dev
Browse files Browse the repository at this point in the history
Scanner Filtering
  • Loading branch information
pradeeban authored Jul 11, 2022
2 parents 6e013ee + 67c0862 commit ed98c58
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 8 additions & 6 deletions modules/suvpar/Suvpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,25 @@


def initialize():
global output_csv, df, device_SN
global output_csv, df, device_SN, scanner_filter
with open('config.json', 'r') as f:
config = json.load(f)

feature_file = config['FeaturesetFile']
filename = config['InputFile']
output_csv = config['OutputFile']
scanner_csv = config['ScannerDetails']
scanner_file = config['ScannerDetails']
scanner_filter = bool(config['ScannerFilter'])
text_file = open(feature_file, "r")
feature_list = text_file.read().split('\n')
scanner_df = pandas.read_csv(scanner_csv, sep=',')
# Consider some Device Serial Number and remove other.
device_SN = scanner_df['DeviceSerialNumber'].tolist()
scanner_file = open(scanner_file, "r")
device_SN = scanner_file.read().split('\n')
df = pandas.read_csv(filename, usecols=lambda x: x in feature_list, sep=',')


def suvpar():
global df, device_SN
global df
# 0x0051100F
# 0x0051100C
# 0x00090010
Expand All @@ -51,7 +52,8 @@ def suvpar():
# Consider only MR. Remove modalities such as PR and SR that are present in the original data.
df = df[df.Modality == "MR"]
# Dataset after removing unwanted Device Serial Number
df = df.loc[df['DeviceSerialNumber'].isin(device_SN)]
if scanner_filter:
df = df.loc[df['DeviceSerialNumber'].isin(device_SN)]
# Check for the AcquisitionTime > SeriesTime case, currently observed in Philips and FONAR scanners.
df['AltCase'] = numpy.where(df['Manufacturer'].str.contains('Philips|FONAR'), True, False)

Expand Down
3 changes: 2 additions & 1 deletion modules/suvpar/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"InputFile": "sample.csv",
"OutputFile": "output.csv",
"ScannerDetails": "scanners.csv",
"ScannerDetails": "scanner.txt",
"ScannerFilter": false,
"FeaturesetFile": "featureset.txt"
}
8 changes: 8 additions & 0 deletions modules/suvpar/scanner.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
scanner1
scanner2
scanner3
scanner4
scanner5
scanner6
scanner7
scanner8

0 comments on commit ed98c58

Please sign in to comment.