From 67c086230c1c8c4e7f1acf74ea3c1599f4bf032a Mon Sep 17 00:00:00 2001 From: Nitesh639 Date: Mon, 11 Jul 2022 16:06:52 +0530 Subject: [PATCH] Scanner Filtering --- modules/suvpar/Suvpar.py | 14 ++++++++------ modules/suvpar/config.json | 3 ++- modules/suvpar/scanner.txt | 8 ++++++++ 3 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 modules/suvpar/scanner.txt diff --git a/modules/suvpar/Suvpar.py b/modules/suvpar/Suvpar.py index 6f67e43..862880e 100644 --- a/modules/suvpar/Suvpar.py +++ b/modules/suvpar/Suvpar.py @@ -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 @@ -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) diff --git a/modules/suvpar/config.json b/modules/suvpar/config.json index 7a46533..d002d69 100644 --- a/modules/suvpar/config.json +++ b/modules/suvpar/config.json @@ -1,6 +1,7 @@ { "InputFile": "sample.csv", "OutputFile": "output.csv", - "ScannerDetails": "scanners.csv", + "ScannerDetails": "scanner.txt", + "ScannerFilter": false, "FeaturesetFile": "featureset.txt" } diff --git a/modules/suvpar/scanner.txt b/modules/suvpar/scanner.txt new file mode 100644 index 0000000..c93a319 --- /dev/null +++ b/modules/suvpar/scanner.txt @@ -0,0 +1,8 @@ +scanner1 +scanner2 +scanner3 +scanner4 +scanner5 +scanner6 +scanner7 +scanner8 \ No newline at end of file