From cef8fe72c29b15e1009fec134ede98f29116cffe Mon Sep 17 00:00:00 2001 From: Darren Christopher Lukas Date: Mon, 30 Dec 2024 11:45:00 +1000 Subject: [PATCH] Updated regex for normal and pos (#177) --- suspect/io/twix.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/suspect/io/twix.py b/suspect/io/twix.py index 8501751..1ffd471 100644 --- a/suspect/io/twix.py +++ b/suspect/io/twix.py @@ -202,21 +202,24 @@ def parse_twix_header(header_string): r" { \d+( -?[0-9\.]+)? }", r"\s*{\s*(-?[0-9\.]+)?\s*}", r"\s*{\s*(-?[0-9\.]+)?\s*}", - r" { \d+ (-?[0-9\.]+)? }" + r" { \d+ (-?[0-9\.]+)? }", + r"[\s\S]*?[\s\S]*?{ (-?[0-9\.]+)?\s?}" ] pos_cor_matches = [ r"sSpecPara\.sVoI\.sPosition\.dCor\s*=\s*(-?[[0-9]*[.]?[0-9]*]{0,})\s*", r" { \d+( -?[0-9\.]+)? }", r"\s*{\s*(-?[0-9\.]+)?\s*}", r"\s*{\s*(-?[0-9\.]+)?\s*}", - r" { \d+ (-?[0-9\.]+)? }" + r" { \d+ (-?[0-9\.]+)? }", + r"[\s\S]*?[\s\S]*?{ (-?[0-9\.]+)?\s?}" ] pos_tra_matches = [ r"sSpecPara\.sVoI\.sPosition\.dTra\s*=\s*(-?[[0-9]*[.]?[0-9]*]{0,})\s*", r" { \d+( -?[0-9\.]+)? }", r"\s*{\s*(-?[0-9\.]+)?\s*}", r"\s*{\s*(-?[0-9\.]+)?\s*}", - r" { \d+ (-?[0-9\.]+)? }" + r" { \d+ (-?[0-9\.]+)? }", + r"[\s\S]*?[\s\S]*?{ (-?[0-9\.]+)?\s?}" ] pos_sag = get_meta_regex(pos_sag_matches, header_string, default=0) pos_cor = get_meta_regex(pos_cor_matches, header_string, default=0) @@ -236,7 +239,7 @@ def parse_twix_header(header_string): r" { \d+( -?[0-9\.]+)? }", r"\s*{\s*(-?[0-9\.]+)?\s*}", r"\s*{\s*(-?[0-9\.]+)?\s*}", - r"\s*{\s*\s*{\s*(-?[0-9\.]+)?\s*}" + r"[\s\S]*?[\s\S]*?{ (-?[0-9\.]+)?\s?}" ] normal_cor_matches = [ r"sSpecPara\.sVoI\.sNormal\.dCor\s*=\s*(-?[[0-9]*[.]?[0-9]*]{0,})\s*$", @@ -244,7 +247,7 @@ def parse_twix_header(header_string): r" { \d+( -?[0-9\.]+)? }", r"\s*{\s*(-?[0-9\.]+)?\s*}", r"\s*{\s*(-?[0-9\.]+)?\s*}", - r"\s*{\s*.*\s*\s*{\s*(-?[0-9\.]+)?\s*}" + r"[\s\S]*?[\s\S]*?{ (-?[0-9\.]+)?\s?}" ] normal_tra_matches = [ r"sSpecPara\.sVoI\.sNormal\.dTra\s*=\s*(-?[[0-9]*[.]?[0-9]*]{0,})\s*$", @@ -252,7 +255,7 @@ def parse_twix_header(header_string): r" { \d+( -?[0-9\.]+)? }", r"\s*{\s*(-?[0-9\.]+)?\s*}", r"\s*{\s*(-?[0-9\.]+)?\s*}", - r"\s*{\s*.*\s*.*\s*\s*{\s*(-?[0-9\.]+)?\s*}" + r"[\s\S]*?[\s\S]*?{ (-?[0-9\.]+)?\s?}" ] in_plane_rot = get_meta_regex(in_plane_rot_matches, header_string, default=0) normal_sag = get_meta_regex(normal_sag_matches, header_string, default=0)