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), ]
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)
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:
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)
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)
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)
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 [