Add a first version of decode system

Add decode function.
Add build array of medians function