Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export_to_phy error: Input contains NaN, infinity or a value too large for dtype('float32'). #477

Closed
phanhuynh opened this issue Mar 4, 2022 · 0 comments · Fixed by #595

Comments

@phanhuynh
Copy link

Hello folks! I'm using kilosort3 on neuropixel 1.0 data in spikeinterface: This error occurs when I export waveforms to phy:

Warning: empty units have been removed when being exported to Phy
write_binary_recording with n_jobs 1  chunk_size 3125000
write_binary_recording: 100%|############################################################| 2/2 [00:00<00:00, 17.85it/s]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [29], in <module>
      1 start_time = time.time()
----> 2 export_to_phy(we_KS3, output_folder='_phy_KS3',
      3               progress_bar=True, total_memory='100M')
      4 print("--- _phy_KS3 took %s seconds ---" % (time.time() - start_time))

File ~\anaconda3\envs\siphy_env\lib\site-packages\spikeinterface\exporters\to_phy.py:161, in export_to_phy(waveform_extractor, output_folder, compute_pc_features, compute_amplitudes, sparsity_dict, copy_binary, max_channels_per_template, remove_if_exists, peak_sign, template_mode, dtype, verbose, **job_kwargs)
    158     templates.append(template_full)
    159     templates_ind.append(inds_full)
--> 161 template_similarity = compute_template_similarity(waveform_extractor, method='cosine_similarity')
    163 np.save(str(output_folder / 'templates.npy'), templates)
    164 np.save(str(output_folder / 'template_ind.npy'), templates_ind)

File ~\anaconda3\envs\siphy_env\lib\site-packages\spikeinterface\toolkit\postprocessing\template_similarity.py:37, in compute_template_similarity(waveform_extractor, waveform_extractor_other, method)
     35     else:
     36         templates_other_flat = None
---> 37     similarity = sklearn.metrics.pairwise.cosine_similarity(templates_flat, templates_other_flat)
     38 # elif method == '':
     39 else:
     40     raise ValueError(f'compute_template_similarity(method {method}) not exists')

File ~\anaconda3\envs\siphy_env\lib\site-packages\sklearn\metrics\pairwise.py:1251, in cosine_similarity(X, Y, dense_output)
   1217 """Compute cosine similarity between samples in X and Y.
   1218 
   1219 Cosine similarity, or the cosine kernel, computes similarity as the
   (...)
   1247 kernel matrix : ndarray of shape (n_samples_X, n_samples_Y)
   1248 """
   1249 # to avoid recursive import
-> 1251 X, Y = check_pairwise_arrays(X, Y)
   1253 X_normalized = normalize(X, copy=True)
   1254 if X is Y:

File ~\anaconda3\envs\siphy_env\lib\site-packages\sklearn\metrics\pairwise.py:147, in check_pairwise_arrays(X, Y, precomputed, dtype, accept_sparse, force_all_finite, copy)
    144     dtype = dtype_float
    146 if Y is X or Y is None:
--> 147     X = Y = check_array(
    148         X,
    149         accept_sparse=accept_sparse,
    150         dtype=dtype,
    151         copy=copy,
    152         force_all_finite=force_all_finite,
    153         estimator=estimator,
    154     )
    155 else:
    156     X = check_array(
    157         X,
    158         accept_sparse=accept_sparse,
   (...)
    162         estimator=estimator,
    163     )

File ~\anaconda3\envs\siphy_env\lib\site-packages\sklearn\utils\validation.py:800, in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, estimator)
    794         raise ValueError(
    795             "Found array with dim %d. %s expected <= 2."
    796             % (array.ndim, estimator_name)
    797         )
    799     if force_all_finite:
--> 800         _assert_all_finite(array, allow_nan=force_all_finite == "allow-nan")
    802 if ensure_min_samples > 0:
    803     n_samples = _num_samples(array)

File ~\anaconda3\envs\siphy_env\lib\site-packages\sklearn\utils\validation.py:114, in _assert_all_finite(X, allow_nan, msg_dtype)
    107     if (
    108         allow_nan
    109         and np.isinf(X).any()
    110         or not allow_nan
    111         and not np.isfinite(X).all()
    112     ):
    113         type_err = "infinity" if allow_nan else "NaN, infinity"
--> 114         raise ValueError(
    115             msg_err.format(
    116                 type_err, msg_dtype if msg_dtype is not None else X.dtype
    117             )
    118         )
    119 # for object dtype data, we only check for NaNs (GH-13254)
    120 elif X.dtype == np.dtype("object") and not allow_nan:

ValueError: Input contains NaN, infinity or a value too large for dtype('float32').
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant