Skip to content

Commit

Permalink
Merge branch 'master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
epnev committed Jan 31, 2019
2 parents f8d40a6 + ef7f21c commit 3a985ba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion caiman/base/movies.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,7 @@ def load(file_name,fr=30,start_time=0,meta_data=None,subindices=None,shape=None,
except:
logging.warning('Your tif file is saved a single page file. Performance will be affected')
input_arr = tffl.asarray()
input_arr = input_arr[subindices[0]]
input_arr = input_arr[subindices]

else:
input_arr = tffl.asarray()
Expand Down
20 changes: 15 additions & 5 deletions caiman/motion_correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def motion_correct_rigid(self, template=None, save_movie=False):
self.shifts_rig: shifts in x and y per frame
"""
logging.debug('Entering Rigid Motion Correction')
logging.debug(-self.min_mov) # XXX why the minus?
logging.debug(-self.min_mov) # XXX why the minus?
self.total_template_rig = template
self.templates_rig = []
self.fname_tot_rig = []
Expand Down Expand Up @@ -2200,7 +2200,7 @@ def motion_correct_batch_rigid(fname, max_shifts, dview=None, splits=56, num_spl
"""
corrected_slicer = slice(subidx.start, subidx.stop, subidx.step * 10)
m = cm.load(fname, subindices=corrected_slicer)

if m.shape[0] < 300:
m = cm.load(fname, subindices=corrected_slicer)
elif m.shape[0] < 500:
Expand All @@ -2209,14 +2209,20 @@ def motion_correct_batch_rigid(fname, max_shifts, dview=None, splits=56, num_spl
else:
corrected_slicer = slice(subidx.start, subidx.stop, subidx.step * 30)
m = cm.load(fname, subindices=corrected_slicer)


if len(m.shape) < 3:
m = cm.load(fname)
m = m[corrected_slicer]
logging.warning("Your original file was saved as a single page " +
"file. Consider saving it in multiple smaller files" +
"with size smaller than 4GB (if it is a .tif file)")
if template is None:
if gSig_filt is not None:
m = cm.movie(
np.array([high_pass_filter_space(m_, gSig_filt) for m_ in m]))

template = cm.motion_correction.bin_median(
m.motion_correct(max_shifts[0], max_shifts[1], template=None)[0])
m.motion_correct(max_shifts[1], max_shifts[0], template=None)[0])

new_templ = template
if add_to_movie is None:
Expand Down Expand Up @@ -2462,7 +2468,11 @@ def motion_correction_piecewise(fname, splits, strides, overlaps, add_to_movie=0
T = len(tf.pages)
if T == 1: # Fiji-generated TIF
is_fiji = True
T, d1, d2 = tf[0].shape
try:
T, d1, d2 = tf[0].shape
except:
T, d1, d2 = tf.asarray().shape
tf.close()
else:
d1, d2 = tf.pages[0].shape

Expand Down

0 comments on commit 3a985ba

Please sign in to comment.