Skip to content

Instantly share code, notes, and snippets.

View andres-fr's full-sized avatar

Andres Fernandez andres-fr

View GitHub Profile
@andres-fr
andres-fr / salsa_features.py
Created February 17, 2022 00:36
On-the-fly CPU computations of the SALSA and SALSA-Lite features for multi-microphone audio source localization.
#!/usr/env/bin python
# -*- coding:utf-8 -*-
"""
This module extracts salsa-related features on-the-fly (CPU).
Inspired by the original SALSA implementation:
github.com/thomeou/SALSA/blob/master/dataset/salsa_lite_feature_extraction.py
(MIT License)
@andres-fr
andres-fr / incremental_hdf5.py
Last active May 13, 2022 15:02
Incrementally concatenate matrices of same height into a HDF5 database efficiently.
#!/usr/bin python
# -*- coding:utf-8 -*-
"""
"""
import numpy as np
import h5py
@andres-fr
andres-fr / plot_complex.py
Created February 1, 2022 22:47
Interactive 3D plot of complex signals for visual inspection
#!/usr/env/bin python
# -*- coding:utf-8 -*-
"""
Interactive plot for visual inspection:
Complex vectors are plotted as lines on a 3D space, such that 2 dimensions are
the real and imaginary components, and the third dimension goes through the
vector values (could be e.g. time or frequency).
@andres-fr
andres-fr / wiener_deconv.py
Last active January 12, 2022 20:02
Wiener deconvolution study
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Wiener deconvolution study.
Copyright (C) 2021 aferro (ORCID: 0000-0003-3830-3595)
This program is free software: you can redistribute it and/or modify
@andres-fr
andres-fr / hsv_histogram.py
Created October 18, 2021 01:49
Python script to plot a 3-dimensional HSV histogram from a color image.
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
HSV image histogram script.
"""
import os
@andres-fr
andres-fr / neo4j_schema.py
Last active February 11, 2021 20:56
Neo4j Schema using py2neo
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Self-contained script that exemplifies the implementation of a pseudo-schema
for Neo4j using py2neo. Specifically:
1. Defines some helper functions for typechecking and CRUD operations
2. Defines the base clase for the schema. Basically, it is a Node and
@andres-fr
andres-fr / commitizen_configless_bump.py
Last active November 1, 2020 20:31
A Config-less `cz bump`
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
ATM commitizen just supports bumping via config file. Since we want a more
interactive approach, re-wrote the class with an explicit interface.
VRS=`python -c "from ml_lib import __version__ as v; print(v)"`
python ci_scripts/commitizen_bump.py -P ml_lib/_metadata.py -v $VRS --changelog
--dry_run
@andres-fr
andres-fr / almat2almat.sc
Created May 8, 2020 12:37
ALMAT 2017 SuperCollider script
(//server config and start
Server.default = s; // = Server.internal;
s.options.memSize = 1500*1024;// up to 1500MB RAM allocable
s.reboot;
//s.quit;
)
(
//s.volume.gui;
//s.plotTree;
@andres-fr
andres-fr / array_masker.py
Created January 15, 2020 18:03
A Python3 script to mask arrays by customizable criteria (e.g. color spheres)
# -*- coding:utf-8 -*-
"""
This script deals with extracting value-based masks from images in various ways.
At some point it might be sensible to use OpenCV to scale further up.
https://www.learnopencv.com/tag/inrange/
Explanation of PIL HSV space:
https://pillow.readthedocs.io/en/latest/reference/ImageColor.html?highlight=hsv#color-names
@andres-fr
andres-fr / python_interfacing_ioc.py
Last active October 2, 2019 15:25
Proper interfacing in Python
# -*- coding:utf-8 -*-
"""
Python's duck typing system allows for very pleasant prototyping. But at some
point, it is convenient to enforce some interfacing. This can be achieved
Through abstract base classes and annotations to a great extent.
Another approach is to use dependency injection and inversion of control
patterns. This gist exemplifies how to do that using ``dependency_injector``.