Skip to content

Commit

Permalink
chore: merge dev into release
Browse files Browse the repository at this point in the history
chore: merge dev into release
  • Loading branch information
versey-sherry authored Apr 5, 2023
2 parents d78c4f5 + f39de68 commit e645689
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion moseq2_extract/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "v1.1.2"
__version__ = "v1.2.0"
8 changes: 7 additions & 1 deletion moseq2_extract/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,16 @@ def download_flip_file(config_file, output_dir):

@cli.command(name="generate-config", help="Generates a configuration file (config.yaml) that holds editable options for extraction parameters.")
@click.option('--output-file', '-o', type=click.Path(), default='config.yaml')
def generate_config(output_file):
@click.option('--camera-type', default='k2', type=str, help='specify the camera type (k2 or azure), default is k2')

def generate_config(output_file, camera_type):

objs = extract.params
params = {tmp.name: tmp.default for tmp in objs if not tmp.required}
if camera_type=='azure':
params['bg_roi_depth_range'] = [550, 650]
params['spatial_filter_size'] = [5]
params['tail_filter_size'] = [15, 15]

with open(output_file, 'w') as f:
yaml.safe_dump(params, f)
Expand Down
2 changes: 1 addition & 1 deletion moseq2_extract/extract/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def extract_chunk(chunk, use_tracking_model=False, spatial_filter_size=(3,),
# Orient mouse to face east
if flip_classifier:
# get frame indices of incorrectly orientation
flips = get_flips(cropped_frames, flip_classifier, flip_classifier_smoothing)
flips = get_flips(cropped_filtered_frames, flip_classifier, flip_classifier_smoothing)
flip_indices = np.where(flips)

# apply flips
Expand Down
6 changes: 5 additions & 1 deletion moseq2_extract/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def parse_input(s):
return ret_extract

@filter_warnings
def generate_config_command(output_file):
def generate_config_command(output_file, camera_type='k2'):
"""
Generate configuration file (config.yaml) to use throughout pipeline.
Expand All @@ -108,6 +108,10 @@ def generate_config_command(output_file):
objs = extract.params

params = {tmp.name: tmp.default for tmp in objs if not tmp.required}
if camera_type=='azure':
params['bg_roi_depth_range'] = [550, 650]
params['spatial_filter_size'] = [5]
params['tail_filter_size'] = [15, 15]

# Check if the file already exists, and prompt user if they would like to overwrite pre-existing file
if exists(output_file):
Expand Down
14 changes: 9 additions & 5 deletions moseq2_extract/helpers/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ def get_roi_wrapper(input_file, config_data, output_dir=None):
config_data['output_dir'] = output_dir

if config_data.get('finfo') is None:
# when depth video is .avi, frame_size/dim is read directly from the video
config_data['finfo'] = get_movie_info(input_file, **config_data)

# checks camera type to set appropriate bg_roi_weights
Expand All @@ -185,7 +186,8 @@ def get_roi_wrapper(input_file, config_data, output_dir=None):
adjusted_bg_depth_range = bground_im[cY][cX]
config_data['bg_roi_depth_range'] = [int(adjusted_bg_depth_range-50), int(adjusted_bg_depth_range+50)]

first_frame = load_movie_data(input_file, 0, **config_data) # there is a tar object flag that must be set!!
# pass in config_data['finfo']['dims'] for frame size otherwise frame size is hard coded to 512x424
first_frame = load_movie_data(input_file, 0, frame_size=config_data['finfo']['dims'], **config_data) # there is a tar object flag that must be set!!
write_image(join(output_dir, 'first_frame.tiff'), first_frame, scale=True,
scale_factor=config_data['bg_roi_depth_range'])

Expand Down Expand Up @@ -402,12 +404,14 @@ def flip_file_wrapper(config_file, output_dir, selected_flip=None):
"""

flip_files = {
'large mice with fibers':
'large mice with fibers (K2)':
"https://storage.googleapis.com/flip-classifiers/flip_classifier_k2_largemicewithfiber.pkl",
'adult male c57s':
'adult male c57s (K2)':
"https://storage.googleapis.com/flip-classifiers/flip_classifier_k2_c57_10to13weeks.pkl",
'mice with Inscopix cables':
"https://storage.googleapis.com/flip-classifiers/flip_classifier_k2_inscopix.pkl"
'mice with Inscopix cables (K2)':
"https://storage.googleapis.com/flip-classifiers/flip_classifier_k2_inscopix.pkl",
'adult male c57s (Azure)':
"https://moseq-data.s3.amazonaws.com/flip-classifier-azure-temp.pkl"
}

key_list = list(flip_files)
Expand Down

0 comments on commit e645689

Please sign in to comment.