You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: expand_values_region2voxel.m
    path of file: ./repos/CanlabCore/CanlabCore/@brainpathway/private
    
    the code of the file until where you have to start completion: function output_dat = expand_values_region2voxel(obj, input_dat)
% Map region-wise values to voxel values
% output_dat = expand_values_region2voxel(obj, input_dat)
%
% obj: A brainpathway object
% input_dat: regions x images values to expand

    
function output_dat = expand_values_region2voxel(obj, input_dat)
% Map region-wise values to voxel values
% output_dat = expand_values_region2voxel(obj, input_dat)
%
% obj: A brainpathway object
% input_dat: regions x images values to expand
% output_dat: voxels x images
%
% Tor Wager, 12/2019

% Integer codes for which voxels belong to each region
voxel_indx = obj.region_atlas.dat;

[n_regions, n_images] = size(input_dat);

output_dat = zeros([size(voxel_indx, 1), n_images]);


for i = 1:n_regions
    
    wh = voxel_indx == i;
    
    for j = 1:n_images
        
        myvalue = input_dat(i, j);
        
        output_dat(wh, j) = myvalue;
        
    end