Skip to content

Commit d808826

Browse files
committed
Update to pathlib
1 parent 1afbe2b commit d808826

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

findoutlie/outfind.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
""" Module with routines for finding outliers
22
"""
33

4-
import os.path as op
5-
from glob import glob
4+
from pathlib import Path
65

76

87
def detect_outliers(fname):
@@ -23,8 +22,7 @@ def find_outliers(data_directory):
2322
Dictionary with keys being filenames and values being lists of outliers
2423
for filename.
2524
"""
26-
image_fnames = glob(op.join(data_directory, '**', 'sub-*.nii.gz'),
27-
recursive=True)
25+
image_fnames = Path(data_directory).glob('**/sub-*.nii.gz')
2826
outlier_dict = {}
2927
for fname in image_fnames:
3028
outliers = detect_outliers(fname)

scripts/find_outliers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
python3 scripts/find_outliers.py data
66
"""
77

8-
import os.path as op
8+
from pathlib import Path
99
import sys
1010

1111
from argparse import ArgumentParser, RawDescriptionHelpFormatter
1212

1313
# Put the findoutlie directory on the Python path.
14-
PACKAGE_DIR = op.join(op.dirname(__file__), '..')
15-
sys.path.append(PACKAGE_DIR)
14+
PACKAGE_DIR = Path(__file__).parent / '..'
15+
sys.path.append(str(PACKAGE_DIR))
1616

1717
from findoutlie import outfind
1818

scripts/validate_data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
python3 scripts/validata_data.py data
66
"""
77

8-
import op as op
8+
from pathlib import Path
99
import sys
1010
import hashlib
1111

0 commit comments

Comments
 (0)