Skip to content

Add configurable binning origin for texture features#328

Open
walkerbdev wants to merge 1 commit intoPolusAI:mainfrom
walkerbdev:bin_origin
Open

Add configurable binning origin for texture features#328
walkerbdev wants to merge 1 commit intoPolusAI:mainfrom
walkerbdev:bin_origin

Conversation

@walkerbdev
Copy link
Copy Markdown
Member

Add binning_origin parameter to control where the intensity binning range starts for texture features: "zero" (default, bins from [0, max], Nyxus/MATLAB behavior) or "min" (bins from [min, max], PyRadiomics-compatible)

@walkerbdev walkerbdev force-pushed the bin_origin branch 2 times, most recently from 7330ee1 to 74e4fd2 Compare March 12, 2026 15:47
Copy link
Copy Markdown
Member

@vjaganat90 vjaganat90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few fixes and then it is good.

// matlab binning (BinningOrigin::zero)
auto n = I.size();
prep_bin_array_matlab (max_I_inten, n_levels);
for (size_t i = 0; i < n; i++)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use for_each or range-based for if order evaluation is not important.

// matlab binning (BinningOrigin::zero)
auto n = I.size();
prep_bin_array_matlab(max_I_inten, n_levels);
for (size_t i = 0; i < n; i++)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

int neighbor_distance = -1,
float pixels_per_micron = -1,
uint32_t coarse_gray_depth = 0,
int coarse_gray_depth = 0,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change from unsigned to signed int?

int ram_limit_mb = -1,
int verb_level = 0)
int verb_level = 0,
const std::string& binning_origin = "")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you are using default values, I recommend using by copy semantics, const std::string. Move semantics make copy-ing zero-cost.

If it has to be a reference I suggest universal reference const std::string&&, but try simple value semantics.

ASSERT_EQ(result, 6);
}

// "min" origin, PyRadiomics-style:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some of these redundant and noisy comments should be cleaned up.

s[(int)NyxSetting::SINGLEROI].bval = false;
s[(int)NyxSetting::GREYDEPTH].ival = -20; // intentionally negative to activate radiomics binCount-based grey-binning
s[(int)NyxSetting::GREYDEPTH].ival = 20;
s[(int)NyxSetting::BINNING_ORIGIN].ival = static_cast<int>(BinningOrigin::min_based);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should use consistent casting, either use C-style (int) or C++-safe static_cast at the same place, not mix-match, I would suggest, convert all these (even where your changes don't touch) to consistent static_cast

}

void Environment::set_coarse_gray_depth(unsigned int new_depth)
void Environment::set_coarse_gray_depth(int new_depth)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again why are we changing the type of depth here? are these unsigned -> signed changes justified/documented?

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 this pull request may close these issues.

2 participants