base_inv) torso_kine_filled, _ = process_trial(stat_markers, filled_marker_pos, compute_trajectory_continuous, base_inv) torso_kine_prev_filled, _ = process_trial(stat_markers, prev_filled_marker_pos, compute_trajectory, base_inv) return TorsoTrajComparisonPlotter(trial.trial_name, torso_kine_prev_filled, torso_kine_smooth, torso_kine_filled, torso_kine_sfs, trial.vicon_endpts) # ready db root_path = Path(params.output_dir) db = create_db(params.biplane_vicon_db_dir, BiplaneViconSubject) db['Plotter'] = db['Trial'].apply( trial_plotter, args=[ StaticTorsoSegment.TRACKING_MARKERS, read_filling_directives(params.filling_directives), db.attrs['dt'] ]) # create plots init_graphing() for subject_name, subject_df in db.groupby('Subject_Name'): log.info('Outputting torso kinematics for subject %s', subject_name) subject_pdf_file = root_path / (subject_name + '.pdf') with PdfPages(subject_pdf_file) as subject_pdf: for plotter in subject_df['Plotter']: if plotter is not None:
from biplane_kine.database import create_db from biplane_kine.database.biplane_vicon_db import ViconCsvSubject from biplane_kine.misc.json_utils import Params from biplane_kine.graphing.common_graph_utils import init_graphing from ..parameters import read_smoothing_exceptions from logging.config import fileConfig # initialize config_dir = Path( mod_arg_parser('Batch smooth Vicon marker data using Kalman smoothing', __package__, __file__)) params = Params.get_params(config_dir / 'parameters.json') # logging fileConfig(config_dir / 'logging.ini', disable_existing_loggers=False) log = logging.getLogger(params.logger_name) # ready db root_path = Path(params.output_dir) db = create_db(params.biplane_vicon_db_dir, ViconCsvSubject) init_graphing() all_exceptions = read_smoothing_exceptions(params.smoothing_exceptions) # create plots for subject_name, subject_df in db.groupby('Subject_Name'): log.info('Smoothing subject %s', subject_name) subject_dir = (root_path / subject_name) subject_dir.mkdir(parents=True, exist_ok=True) for t in subject_df['Trial']: trial_plotter(t, db.attrs['dt'], subject_dir, all_exceptions)
params = Params.get_params(config_dir / 'parameters.json') # logging fileConfig(config_dir / 'logging.ini', disable_existing_loggers=False) log = logging.getLogger(params.logger_name) # ready db class C3DSubjectEndptsPrePop(C3DSubjectEndpts): """Proxy for C3DSubjectEndpts where the labeled_base_dir and filled_base_dir are pre-populated.""" def __init__(self, subj_dir: Union[str, Path]): super().__init__(subj_dir, labeled_base_dir=params.labeled_c3d_dir, filled_base_dir=params.filled_c3d_dir, c3d_trial_cls=C3DTrialEndptsNonHom) root_path = Path(params.output_dir) db = create_db(params.biplane_vicon_db_dir, C3DSubjectEndptsPrePop) # select trial trial_row = db.loc[params.trial_name] sel_trial = trial_row.Trial log.info('Filtering trial %s marker %s', params.trial_name, params.marker_name) # filter and plot marker_exceptions = smoothing_exceptions_for_marker(params.smoothing_exceptions, params.trial_name, params.marker_name) init_graphing() subject_dir = Path(params.output_dir) / trial_row.Subject_Name if \ bool(distutils.util.strtobool(params.print_to_file)) else None try: marker_plotter(sel_trial, params.marker_name, marker_exceptions, db.attrs['dt'], SmoothingOutputPlotter, subject_dir)
from biplane_kine.graphing.common_graph_utils import init_graphing from biplane_kine.misc.arg_parser import mod_arg_parser import logging from logging.config import fileConfig # initialize config_dir = Path(mod_arg_parser('Demonstrates the effect of smoothing for a specified trial/marker', __package__, __file__)) params = Params.get_params(config_dir / 'parameters.json') # logging fileConfig(config_dir / 'logging.ini', disable_existing_loggers=False) log = logging.getLogger(params.logger_name) # ready db db = create_db(params.accuracy_db_dir, BiplaneMarkerSubjectEndpts) add_c3d_helper(db, params.labeled_c3d_dir, params.filled_c3d_dir) # select trial trial_row = db.loc[params.trial_name] marker_exceptions = smoothing_exceptions_for_marker(params.smoothing_exceptions, params.trial_name, params.marker_name) # compute differences try: raw_smoothed_diff = marker_accuracy_diff(trial_row['Biplane_Marker_Trial'], trial_row['C3D_Trial'], params.marker_name, marker_exceptions, db.attrs['dt'], bool(distutils.util.strtobool(params.use_filled_portion))) except InsufficientDataError as e: log.error('Insufficient data for trial {} marker {}: {}'.format(params.trial_name, params.marker_name, e)) sys.exit(1)
__package__, __file__)) params = Params.get_params(config_dir / 'parameters.json') # logging fileConfig(config_dir / 'logging.ini', disable_existing_loggers=False) log = logging.getLogger(params.logger_name) # ready db root_path = Path(params.output_dir) anthro = anthro_db(params.biplane_vicon_db_dir) def armpit_thickness(subject_name): return anthro.loc[subject_name, 'Armpit_Thickness'] db = create_db(params.biplane_vicon_db_dir, BiplaneViconSubjectV3D, armpit_thickness=armpit_thickness) # retrieve trial information trial_row = db.loc[params.trial_name] subject_id = trial_row['Subject_Name'] trial = trial_row['Trial'] tracking_markers = np.stack([ trial.filled[marker] for marker in StaticTorsoSegment.TRACKING_MARKERS ], 0) torso_vicon = compute_trajectory( trial.subject.torso.static_markers_intrinsic, tracking_markers) torso_fluoro = change_cs(trial.subject.f_t_v, torso_vicon) torso_truncated = torso_fluoro[trial.vicon_endpts[0]:trial.vicon_endpts[1]] quat = quaternion.as_float_array( quaternion.from_rotation_matrix(torso_truncated[:, :3, :3],