예제 #1
0
        num=rex_named(float_ptn, 'kernel'),
        mm=mm_ptn,
        fw=fw_ptn,
        dlm=delimiter,
    ), r'''
        {halfmax}{dlm}
        (of|at|(set{dlm}to)|(equal{dlm}to))?{dlm}
        ({num}){dlm}{mm}
    '''.format(
        dlm=delimiter,
        halfmax=hm_ptn,
        num=rex_named(float_ptn, 'kernel'),
        mm=mm_ptn,
    )
]
smooth_spatial_ptn = [rex_compile(ptn) for ptn in smooth_spatial_ptn]

MAX_FWHM = 30


def est_smooth_kernel(txt):

    # Initialize FWHM
    kernels = []

    ctxt = re.sub(r'[():=]', '', txt)

    for ptn in smooth_spatial_ptn:

        matches = rex_flex(ptn, ctxt, re.finditer)
from ..misc import delimiter, float_ptn

# S or Hz not followed by numbers
# To avoid s-1 units
hpf_unit_ptn = ur'''
    (
        s(ec(onds?)?)?
        |
        hz
    )
    (?!\w)
    (?!\s*\d)
'''

highpass_filter_bool_ptn = [
    rex_compile(ptn)
    for ptn in [
        r'high{dlm}pass'.format(dlm=delimiter)
    ]
]

highpass_filter_neg_ptn = [
    rex_compile(ptn)
    for ptn in [
        r'stimul(i|us)',
        r'gaussian',
        r'half{dlm}max'.format(dlm=delimiter),
        r'low{dlm}pass'.format(dlm=delimiter),
        r'temporal(ly)?{dlm}smooth'.format(dlm=delimiter),
        r'smooth(ed|ing)?{dlm}temporal'.format(dlm=delimiter),
    ]
예제 #3
0
 def test_compile_pattern(self):
     rex = rex_compile(r'foo', flags=re.I)
     assert_equal(rex.pattern, r'foo')
     assert_equal(rex.flags, re.I)
예제 #4
0
from neurotrends.tagger import CustomTagger
from ..misc import delimiter

MIN_FIELD_STRENGTH = 0.5
MAX_FIELD_STRENGTH = 12

# Magnet patterns
vend_ptn = r'siemens|philips|general{dlm}electric|\Wge\W'.format(dlm=delimiter)
scan_ptn = r'magnet|scan(ner)?|mri|field|system'
mag_ptn = r'({vend}|{scan})'.format(vend=vend_ptn, scan=scan_ptn)

tesla_ptn = r'(tesla|t(?!\w|{dlm}=|{dlm}\d+|\())'.format(dlm=delimiter)
num_ptn = r'[\s\(](\d{1,2}\.?\d{,2})(?!=\d)'

field_ptn = [
    rex_compile(rex_named(num_ptn, 'field') + delimiter + tesla_ptn),
]

sig_ptn = 'p{dlm}[<=>]+{dlm}\d?\.\d+'.format(dlm=delimiter)
sig_ptn = rex_compile(sig_ptn)


def est_field_strength(txt):

    fields = []

    for ptn in field_ptn:

        matches = rex_flex(ptn, txt, fun=re.finditer)

        for match in matches:
예제 #5
0
        fw=fw_ptn,
        dlm=delimiter,
    ),
    r'''
        {halfmax}{dlm}
        (of|at|(set{dlm}to)|(equal{dlm}to))?{dlm}
        ({num}){dlm}{mm}
    '''.format(
        dlm=delimiter,
        halfmax=hm_ptn,
        num=rex_named(float_ptn, 'kernel'),
        mm=mm_ptn,
    )
]
smooth_spatial_ptn = [
    rex_compile(ptn) for ptn in smooth_spatial_ptn
]

MAX_FWHM = 30

def est_smooth_kernel(txt):

    # Initialize FWHM
    kernels = []

    ctxt = re.sub(r'[():=]', '', txt)

    for ptn in smooth_spatial_ptn:

        matches = rex_flex(ptn, ctxt, re.finditer)
예제 #6
0
from neurotrends.tagger import CustomTagger
from ..misc import delimiter

MIN_FIELD_STRENGTH = 0.5
MAX_FIELD_STRENGTH = 12

# Magnet patterns
vend_ptn = r'siemens|philips|general{dlm}electric|\Wge\W'.format(dlm=delimiter)
scan_ptn = r'magnet|scan(ner)?|mri|field|system'
mag_ptn = r'({vend}|{scan})'.format(vend=vend_ptn, scan=scan_ptn)

tesla_ptn = r'(tesla|t(?!\w|{dlm}=|{dlm}\d+|\())'.format(dlm=delimiter)
num_ptn = r'[\s\(](\d{1,2}\.?\d{,2})(?!=\d)'

field_ptn = [
    rex_compile(rex_named(num_ptn, 'field') + delimiter + tesla_ptn),
]

sig_ptn = 'p{dlm}[<=>]+{dlm}\d?\.\d+'.format(dlm=delimiter)
sig_ptn = rex_compile(sig_ptn)

def est_field_strength(txt):

    fields = []

    for ptn in field_ptn:

        matches = rex_flex(ptn, txt, fun=re.finditer)

        for match in matches:
예제 #7
0
 def test_compile_rex(self):
     rex = rex_compile(re.compile(r'foo', flags=re.I))
     assert_equal(rex.pattern, r'foo')
     assert_equal(rex.flags, re.I)
예제 #8
0
from neurotrends.tagger import CustomTagger
from ..misc import delimiter, float_ptn

# S or Hz not followed by numbers
# To avoid s-1 units
hpf_unit_ptn = ur"""
    (
        s(ec(onds?)?)?
        |
        hz
    )
    (?!\w)
    (?!\s*\d)
"""

highpass_filter_bool_ptn = [rex_compile(ptn) for ptn in [r"high{dlm}pass".format(dlm=delimiter)]]

highpass_filter_neg_ptn = [
    rex_compile(ptn)
    for ptn in [
        r"stimul(i|us)",
        r"gaussian",
        r"half{dlm}max".format(dlm=delimiter),
        r"low{dlm}pass".format(dlm=delimiter),
        r"temporal(ly)?{dlm}smooth".format(dlm=delimiter),
        r"smooth(ed|ing)?{dlm}temporal".format(dlm=delimiter),
    ]
]

highpass_filter_wide_neg_ptn = [
    rex_compile(ptn)
예제 #9
0
from ..misc import delimiter, float_ptn

# S or Hz not followed by numbers
# To avoid s-1 units
hpf_unit_ptn = ur'''
    (
        s(ec(onds?)?)?
        |
        hz
    )
    (?!\w)
    (?!\s*\d)
'''

highpass_filter_bool_ptn = [
    rex_compile(ptn) for ptn in [r'high{dlm}pass'.format(dlm=delimiter)]
]

highpass_filter_neg_ptn = [
    rex_compile(ptn) for ptn in [
        r'stimul(i|us)',
        r'gaussian',
        r'half{dlm}max'.format(dlm=delimiter),
        r'low{dlm}pass'.format(dlm=delimiter),
        r'temporal(ly)?{dlm}smooth'.format(dlm=delimiter),
        r'smooth(ed|ing)?{dlm}temporal'.format(dlm=delimiter),
    ]
]

highpass_filter_wide_neg_ptn = [
    rex_compile(ptn) for ptn in [