Skip to content

Commit

Permalink
STYL: Fix flake8 errors
Browse files Browse the repository at this point in the history
Add ignores for 504 and 605 (new line after binary operator and invalid escape sequence, both were giving false positives)

Fix Regex match pattern errors (missing `r` prefix to the pattern strings).
  • Loading branch information
JoostJM committed Nov 12, 2018
1 parent c828b99 commit 83b510c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ ignore:
E701,
# .has_key() is deprecated, use 'in'
W601,
# line break after binary operator
W504,

select: C,E,W,F,I
# flake8-import-order
application-import-names: radiomics,testUtils
Expand Down
19 changes: 6 additions & 13 deletions labs/pyradiomics-dcm/pyradiomics-dcm.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ def prefix2codes(self, prefix):
"modifierValue": self.makePrivateCode("Exponent transformation")})

# parameterized processing operations
elif re.match("wavelet-([HL]{2,3})", prefix):
match = re.match("wavelet-([HL]{2,3})", prefix)
elif re.match(r"wavelet-([HL]{2,3})", prefix):
match = re.match(r"wavelet-([HL]{2,3})", prefix)
modifiers.append({"modifier": imageTransformationConcept,
"modifierValue": self.makePrivateCode("Wavelet transformation")})
modifiers.append({"modifier": self.makePrivateCode("Wavelet sub-band"),
"modifierValue": self.makePrivateCode(match.group(1))})

elif re.match("log-sigma-([\d]+)-([\d]+)-([a-z]+)", prefix):
match = re.match("log-sigma-([\d]+)-([\d]+)-([a-z]+)", prefix)
elif re.match(r"log-sigma-([\d]+)-([\d]+)-([a-z]+)", prefix):
match = re.match(r"log-sigma-([\d]+)-([\d]+)-([a-z]+)", prefix)

units = match.group(3)
if units == "mm":
Expand Down Expand Up @@ -286,11 +286,7 @@ def addMeasurement(
quantityCode)
return
except Exception as e:
scriptlogger.error(
"Exception checking for NaN: " +
str(e) +
" " +
value)
scriptlogger.error("Exception checking for NaN: %s %s", str(e), value)
return

measurement["value"] = '%E' % Decimal(value)
Expand Down Expand Up @@ -559,10 +555,7 @@ def main():
dcm = pydicom.read_file(outputSRTempFile)
shutil.move(
outputSRTempFile,
os.path.join(
args.outputDir,
dcm.SOPInstanceUID +
".dcm"))
os.path.join(args.outputDir, dcm.SOPInstanceUID + ".dcm"))
except BaseException:
scriptlogger.error("Failed to move output SR!")

Expand Down
2 changes: 1 addition & 1 deletion radiomics/featureextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def loadImage(self, ImageFilePath, MaskFilePath):
return image, mask

def computeFeatures(self, image, mask, imageTypeName, **kwargs):
"""
r"""
Compute signature using image, mask, \*\*kwargs settings.
This function computes the signature for just the passed image (original or derived), it does not preprocess or
Expand Down
2 changes: 1 addition & 1 deletion radiomics/imageoperations.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ def normalizeImage(image, **kwargs):


def resegmentMask(imageNode, maskNode, **kwargs):
"""
r"""
Resegment the Mask based on the range specified by the threshold(s) in ``resegmentRange``. Either 1 or 2 thresholds
can be defined. In case of 1 threshold, all values equal to or higher than that threshold are included. If there are
2 thresholds, all voxels with a value inside the closed-range defined by these thresholds is included
Expand Down

0 comments on commit 83b510c

Please sign in to comment.